Forum Discussion
Returning the THIRD date
I need to pull specifically the date of the third order of each customer due to a promotion. What I need is very similar to the formulas FIRSTDATE() and LASTDATE(), except for the fact that I need the third one.
Have anyone ever faced this? I tried with TOPN but it didn't work and I can't find something similar in the forums.
Thanks in advance
Hi,
I am not sure how your dataset looks like, but I tried to create a sample pbix file like below.
Please check the below picture and the attached pbix file.
I hope the below can provide some ideas on how to create a solution for your dataset.
I suggest creating a measure for searching the latest date inside TOP3 (ascending) dates.
last date of Top three ascending: = IF ( HASONEVALUE ( Customer[Customer] ), MAXX ( TOPN ( 3, Data, Data[Order_Date], ASC ), Data[Order_Date] ) )
3 Replies
- Jihwan_KimSuper User
Hi,
I am not sure how your dataset looks like, but I tried to create a sample pbix file like below.
Please check the below picture and the attached pbix file.
I hope the below can provide some ideas on how to create a solution for your dataset.
I suggest creating a measure for searching the latest date inside TOP3 (ascending) dates.
last date of Top three ascending: = IF ( HASONEVALUE ( Customer[Customer] ), MAXX ( TOPN ( 3, Data, Data[Order_Date], ASC ), Data[Order_Date] ) )- luanamoreschiFrequent Visitor
Thank you so much! Exaclty what I needed.
Just one more doubt, is it possible to ignore blank date values in this formula? Like, sometimes, when the purchase is not concluded, the date value remains blank and this is considering to the top 3.
Thanks again!!- Jihwan_KimSuper User
Hi,
Thank you for your feedback.
When checking the TOPN function, the second parameter is for inputting a table to iterate to get top 3 or bottom 3 depending on what you select between ascending vs. decending. When inputting the table into the TOPN function, If you filter out the blank, this will make iterate without considering the blank.
I hope this helps.
Thank you.