cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Need help with measures - Finding donors who gave gifts within the past 12 months

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:

 

  • customer_id
  • date
  • gift_id

Any help would be much appreciated.

 

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Need help with measures - Finding donors who gave gifts within the past 12 months

Hi, @PFlorenzano74 

 

Based on your description, i created data to reproduce your scenario.

w1.png

 

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:

w2.png

 

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.

View solution in original post

3 REPLIES 3
Highlighted
Super User IX
Super User IX

Re: Need help with measures - Finding donors who gave gifts within the past 12 months

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



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

Highlighted
Community Support
Community Support

Re: Need help with measures - Finding donors who gave gifts within the past 12 months

Hi, @PFlorenzano74 

 

Based on your description, i created data to reproduce your scenario.

w1.png

 

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:

w2.png

 

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.

View solution in original post

Highlighted
Frequent Visitor

Re: Need help with measures - Finding donors who gave gifts within the past 12 months

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:

 

Sample Data SetSample Data Set

 

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Upcoming Events

Experience what’s next for Power BI

See the latest Power BI innovations, updates, and demos from the Microsoft Business Applications Launch Event.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

Mark your calendars and join us for our next Power BI Dev Camp!.

Top Solution Authors
Top Kudoed Authors