Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
In the same script, I want this result : If the filter YEAR is active then show me the previous year else if the filter MONTH is active then show me the previous month.
If(WildMatch(GetCurrentSelections(), 'active selection YEAR', count({<VisitDate={">=$(=YearStart(Max(VisitDate),-1)) <=$(=YearEnd(Max(VisitDate),-1))" }, PDV_Boolean={1}>} ProductId&StoreId))
If(WildMatch(GetCurrentSelections(), 'active selection MONTH', count({<VisitDate={">=$(=MonthStart(Max(VisitDate),-1)) <=$(=MonthEnd(Max(VisitDate),-1))" }, PDV_Boolean={1}>} ProductId&StoreId))
if(GetSelectedCount () didn't work, but I used If(WildMatch(GetCurrentSelections(), '*Month*') with {<VisitDate={ ">=$(=MonthStart(Max(VisitDate))) <=$(=Max(VisitDate))"} for the current month and {<VisitDate={">=$(=MonthStart(Max(VisitDate),-1)) <=$(=MonthEnd(Max(VisitDate),-1))"} for the previous month.
Hi,
Can you share the sample data set, and expected output result.
Hi,
I would not be using Wildmatch but GetSelectedCount that gives you the number of selected values for a field
i.e.
if(GetSelectedCount ([Year]) >0,
count({<VisitDate={">=$(=YearStart(Max(VisitDate),-1)) <=$(=YearEnd(Max(VisitDate),-1))" }, PDV_Boolean={1}>} ProductId&StoreId)),
if(GetSelectedCount ([Month])>0,
count({<VisitDate={">=$(=MonthStart(Max(VisitDate),-1)) <=$(=MonthEnd(Max(VisitDate),-1))" }, PDV_Boolean={1}>} ProductId&StoreId)),
.... else ..
)
Also, if you want to keep using Wildmatch, be sure to take a look at GetCurrentSelections() and Wildmatch() functions :
GetCurrentSelections() will send you someting like 'Year: 2020, 2019; ProductId:3'
To catch it with Wildmatch, you would try someting like if(Wildmatch(GetCurrentSelections(),'*Year:*'), count(XXXX))
if(GetSelectedCount () didn't work, but I used If(WildMatch(GetCurrentSelections(), '*Month*') with {<VisitDate={ ">=$(=MonthStart(Max(VisitDate))) <=$(=Max(VisitDate))"} for the current month and {<VisitDate={">=$(=MonthStart(Max(VisitDate),-1)) <=$(=MonthEnd(Max(VisitDate),-1))"} for the previous month.