gpt4 book ai didi

qliksense - 在 pick 函数中使用表达式

转载 作者:行者123 更新时间:2023-12-04 06:20:48 32 4
gpt4 key购买 nike

我已经单独尝试了 Num((today()-I_TRAN_DATE)/90 + 1,0) 并且它会返回整数,但是当我尝试将它与 pick 函数结合使用时它似乎不起作用。我知道它还没有完成,但至少应该返回 1-3 的结果

pick(
Num((today()-I_TRAN_DATE)/90 + 1,0)
,'less than 3 months'
,'3-6 months'
,'6-12 months'
,'greater than 1 year'
)

最佳答案

这看起来像是将数字从表达式传递到 pick 函数的问题。使用 num 函数时,这不会更改基础值 - 包括更多的括号和圆形函数可根据以下脚本解决问题,该脚本生成日期列表,然后在最后应用 pick 函数。

Let varMinDate = Num(31350);  //30/10/1985
Let varMaxDate = Num(42400); //31/01/2016

TempCalendar:
LOAD
$(varMinDate) + Iterno()-1 As Num,
Date($(varMinDate) + IterNo() - 1) as TempDate
AutoGenerate 1 While $(varMinDate) + IterNo() -1 <= $(varMaxDate);

TestCalendar:
Load
TempDate AS I_TRAN_DATE,
week(TempDate) As Week,
Year(TempDate) As Year,
Month(TempDate) As PeriodMonth,
Day(TempDate) As Day,
if(Year2Date(TempDate),1,0) as CurYTDFlag,
if(Year2Date(TempDate,-1),1,0) as LastYTDFlag,
inyear(TempDate, Monthstart($(varMaxDate)),-1) as RC12,
date(monthstart(TempDate), 'MMM-YYYY') as MonthYear,
Week(weekstart(TempDate)) & '-' & WeekYear(TempDate) as WeekYear,
WeekDay(TempDate) as WeekDay,
if(TempDate>=MonthStart(AddMonths(Today(),-12)) and(TempDate<=MonthStart(Today())),1,0) as Rolling12Month
,'Q' & Ceil (Month(TempDate)/3) as Quarter
,Year(TempDate)&'-Q' & Ceil (Month(TempDate)/3) as YearQuarter
,if(Year(TempDate)=(Year(Today())-1),1,0) as LastYear
, if(MonthStart(TempDate)=MonthStart(Today()),null(),'Exclude Current Period') As ExcludeCurrentPeriod
Resident TempCalendar
Order By TempDate ASC;
Drop Table TempCalendar;

Let varMinDate = null();
Let varMaxDate = null();


PeriodTable:
Load
Pick(round((num((((today()-I_TRAN_DATE)/90) + 1),0)),1)
,'less than 3 months'
,'3-6 months'
,'6-12 months'
,'greater than 1 year') as Period
,I_TRAN_DATE
Resident TestCalendar;

关于qliksense - 在 pick 函数中使用表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34958945/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com