Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hello,
I have a problem to solve where we have a list of customers that I need to identify who first gave a gift within the past 12 months and after 5 years since their previous gift.
Below are the following fields that I'm working with:
Any help would be much appreciated.
Thank you
Solved! Go to Solution.
Hi, @Anonymous
Based on your description, i created data to reproduce your scenario.
You can create a table as below.
Table 2 = SUMMARIZECOLUMNS('Table'[customer_id],"LastestDate",MAX('Table'[date]),"PreviousDate",
CALCULATE(MAX('Table'[date]),FILTER('Table',[date]<MAX('Table'[date]))))
You can create a measure as below.
TestMeasure = var LastestDate = MAX('Table'[date])
var PreviousDate=CALCULATE(MAX('Table'[date]),FILTER('Table',[date]<LastestDate))
return IF(LastestDate>NOW()-365&&PreviousDate>LastestDate-365*6,1,BLANK())
Result:
If I misunderstand the your thoughts, please show us your sample data and expected output. I am glad to solve the problem for you.
Best Regards,
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @Anonymous
Based on your description, i created data to reproduce your scenario.
You can create a table as below.
Table 2 = SUMMARIZECOLUMNS('Table'[customer_id],"LastestDate",MAX('Table'[date]),"PreviousDate",
CALCULATE(MAX('Table'[date]),FILTER('Table',[date]<MAX('Table'[date]))))
You can create a measure as below.
TestMeasure = var LastestDate = MAX('Table'[date])
var PreviousDate=CALCULATE(MAX('Table'[date]),FILTER('Table',[date]<LastestDate))
return IF(LastestDate>NOW()-365&&PreviousDate>LastestDate-365*6,1,BLANK())
Result:
If I misunderstand the your thoughts, please show us your sample data and expected output. I am glad to solve the problem for you.
Best Regards,
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hello all,
Thank you for your replies, I believe I'm on the right track but have a question for @v-alq-msft ,
The sample measure that you put together:
TestMeasure = var LastestDate = MAX('Table'[date])
var PreviousDate=CALCULATE(MAX('Table'[date]),FILTER('Table',[date]<LastestDate))
return IF(LastestDate>NOW()-365&&PreviousDate>LastestDate-365*6,1,BLANK())
Should I be using the calulated table 'Table 2' to be referenced within the measure like this below:
TestMeasure = var LastestDate = MAX('Table 2'[date])
var PreviousDate=CALCULATE(MAX('Table 2'[date]),FILTER('Table 2',[date]<LastestDate))
return IF(LastestDate>NOW()-365&&PreviousDate>LastestDate-365*6,1,BLANK())
Or should I reference the original table? I tried both but receiving a 1 for all the values, regardless if it fits the criteria or not.
Below is a sample of table 2:
You can use earlier to get the last date.
for rolling 12 month you can get values like. No using date diff ealier date and date and rolling 12 month data you can create a flag
Rolling 12 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date Filer],ENDOFMONTH(Sales[Sales Date]),-12,MONTH))
earlier
https://community.powerbi.com/t5/Desktop/Explanation-of-the-EARLIER-formula/td-p/529469
Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks.
My Recent Blog - https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
108 | |
100 | |
78 | |
64 | |
58 |
User | Count |
---|---|
148 | |
113 | |
97 | |
84 | |
67 |