Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
saminouari
Contributor III
Contributor III

If WildMatch GetCurrentSelections()

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))

Labels (1)
1 Solution

Accepted Solutions
saminouari
Contributor III
Contributor III
Author

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.


View solution in original post

3 Replies
nisha_rai
Creator II
Creator II

Hi,

Can you share the sample data set, and expected output result.

 

 

AntoninMaillard
Contributor
Contributor

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))

 

 

saminouari
Contributor III
Contributor III
Author

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.