Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

ytd and mtd

how to do Distinct count of customer if last transaction is within date filter criteria.  If no date filter is selected then criteria is YTD start date and end date???

9 Replies
Anonymous
Not applicable
Author

Can you give few more details related your requirement.

Anonymous
Not applicable
Author

i need to write a logic in which i need to get distinct count of customer if the transaction is with in date filter criteria. If any date does not get selected then it show data of YTD start date and end date??? Can you pls help??

Anonymous
Not applicable
Author

So is it like you want the distinct count(Data) for selected date range or date and if nothing is selected the values from YTD Start to YTD End should be counted?? Can you  please share some data or sample qvw.

Anonymous
Not applicable
Author

And Please uncheck the correct answer, Some of the expert can come to help if the question is still unanswered. Once you get your answer, then mark it as correct answer. Welcome to Qlik

Anil_Babu_Samineni

As i assume, This?

If(GetFieldSelections([last transaction])=0, count({<Year=, Month=, Quarter=, Week=, [last transaction]={">=$(=Num(YearStart(Max([last transaction]))))<=$(=Max([last transaction]))"}>} customer),

Count({<[last transaction] = {"$(=FirstSorterValue([last transaction], -Aggr(Sum(customer,[last transaction])))"}>}DISTINCT customer))


Or


If(GetFieldSelections([last transaction])>=2, count({<Year=, Month=, Quarter=, Week=, [last transaction]={">=$(=Num(YearStart(Max([last transaction]))))<=$(=Max([last transaction]))"}>} customer),

Count({<[last transaction] = {"$(=FirstSorterValue([last transaction], -Aggr(Sum(customer,[last transaction])))"}>}DISTINCT customer))

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Anonymous
Not applicable
Author

Anil, Shouldn't we use GetSelectedCount() instead of GetFieldSelections() in the expression above??  Am not completely familiar with qlikview. Just asking.

Anil_Babu_Samineni

We can use the same like GetSelectedCount([last transactio])>=2. The reason i used is today morning i got one issue while this so that i can use Field instead of Selected. It works some cases and may be frustrate on few cases

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Anonymous
Not applicable
Author

i need the count of customer when user selects particular date in date filter.But if there is no date selected it will show data of ytd .

Anil_Babu_Samineni

For first one it will come direct.

If(GetFieldSelections([last transaction])=0, YTD Formulae,count(customer))

YTQ, QTD, MTD and WTD

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful