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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
powerbiexpert22
Impactful Individual
Impactful Individual

new donors and repeat donors in line chart based on year selection

i need to create line chart which should show two measures - "new donors" and "repeat donors" by months ( month should be on x axis) . months should display default for year 2024 , user can select year and it should display months on x axis based on selected year by user. i need help on DAX for these two measures

 

logic for new donors:  if donor has not donated in earlier months starting from Dec 2023 until current month then it is a new Donor,  example for January 2024 based on below data, new donors should be 2 and 3 because they did not donate in Dec 2023 . 

 

logic for repeated donors: if donor has donated in earlier months starting from Dec 2023 until current month then it is a repeated Donor,  example for January 2024 based on below data, repeated donors should be 1 and 4 because they donated in Dec 2023 

 

donation_idalumni_id donation_date_keydonation_amount
112023121610
21202401015
322024010120
422024020135
532024011015
642023120120
742024011525
852024020140
962024030135
1062024040110
1172024050110
1 ACCEPTED SOLUTION
danextian
Super User
Super User

Hi @powerbiexpert22 

Use a separate dates table with a one-to-many single direction relationship to your fact table on donation date (donation date key converted to date)

danextian_1-1757079904999.png

 

and create these measures

New Donors = 
VAR _pastDonors =
    CALCULATETABLE (
        VALUES ( SampleData[alumni_id] ),
        FILTER ( ALL ( 'Calendar' ), 'Calendar'[Date] < MIN ( 'Calendar'[Date] ) )
    )
RETURN
    COUNTROWS ( EXCEPT ( VALUES ( SampleData[alumni_id] ), _pastDonors ) )


Repeat Donors = 
VAR _pastDonors =
    CALCULATETABLE (
        VALUES ( SampleData[alumni_id] ),
        FILTER ( ALL ( 'Calendar' ), 'Calendar'[Date] < MIN ( 'Calendar'[Date] ) )
    )
RETURN
    COUNTROWS ( INTERSECT ( VALUES ( SampleData[alumni_id] ), _pastDonors ) )

danextian_0-1757079859825.png

Please see the attached pbix.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

PBI file attached.

Ashish_Mathur_0-1757299912547.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
ThxAlot
Super User
Super User

Easy enough,

ThxAlot_1-1757311872826.png

 

 

For fun only, to showcase power of Excel formulas,

ThxAlot_1-1757283297532.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LearnAndPractise(Everyday)


)



danextian
Super User
Super User

Hi @powerbiexpert22 

Use a separate dates table with a one-to-many single direction relationship to your fact table on donation date (donation date key converted to date)

danextian_1-1757079904999.png

 

and create these measures

New Donors = 
VAR _pastDonors =
    CALCULATETABLE (
        VALUES ( SampleData[alumni_id] ),
        FILTER ( ALL ( 'Calendar' ), 'Calendar'[Date] < MIN ( 'Calendar'[Date] ) )
    )
RETURN
    COUNTROWS ( EXCEPT ( VALUES ( SampleData[alumni_id] ), _pastDonors ) )


Repeat Donors = 
VAR _pastDonors =
    CALCULATETABLE (
        VALUES ( SampleData[alumni_id] ),
        FILTER ( ALL ( 'Calendar' ), 'Calendar'[Date] < MIN ( 'Calendar'[Date] ) )
    )
RETURN
    COUNTROWS ( INTERSECT ( VALUES ( SampleData[alumni_id] ), _pastDonors ) )

danextian_0-1757079859825.png

Please see the attached pbix.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
bhanu_gautam
Super User
Super User

@powerbiexpert22 

Ensure you have a Date table in your model with a continuous range of dates, including the year 2024.

New Donors Measure

New Donors =
VAR CurrentMonth = MAX('Date'[Month])
VAR CurrentYear = MAX('Date'[Year])
VAR CurrentDate = MAX('Date'[Date])
VAR PreviousDonations =
CALCULATETABLE(
VALUES('Donations'[alumni_id]),
'Donations'[donation_date_key] < CurrentDate,
'Donations'[donation_date_key] >= DATE(CurrentYear - 1, 12, 1)
)
RETURN
COUNTROWS(
FILTER(
VALUES('Donations'[alumni_id]),
NOT('Donations'[alumni_id] IN PreviousDonations) &&
CALCULATE(MIN('Donations'[donation_date_key])) >= DATE(CurrentYear, CurrentMonth, 1) &&
CALCULATE(MIN('Donations'[donation_date_key])) < EOMONTH(CurrentDate, 0)
)
)

 

Repeat Donors Measure

DAX
Repeat Donors =
VAR CurrentMonth = MAX('Date'[Month])
VAR CurrentYear = MAX('Date'[Year])
VAR CurrentDate = MAX('Date'[Date])
VAR PreviousDonations =
CALCULATETABLE(
VALUES('Donations'[alumni_id]),
'Donations'[donation_date_key] < CurrentDate,
'Donations'[donation_date_key] >= DATE(CurrentYear - 1, 12, 1)
)
RETURN
COUNTROWS(
FILTER(
VALUES('Donations'[alumni_id]),
'Donations'[alumni_id] IN PreviousDonations &&
CALCULATE(MIN('Donations'[donation_date_key])) >= DATE(CurrentYear, CurrentMonth, 1) &&
CALCULATE(MIN('Donations'[donation_date_key])) < EOMONTH(CurrentDate, 0)
)
)

 

Steps to Create the Line Chart
Add a slicer to your report to allow users to select the year.
Add a line chart visual to your report.
Configure the Line Chart:
Set the X-axis to the 'Month' field from your Date table.
Add the "New Donors" and "Repeat Donors" measures to the Values field.




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.