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

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.

Reply
kdsan
Regular Visitor

Count based on change in year

Good morning. 

 

PowerBI newbie here.  I have used power query before and, to a (much) lesser extent, power pivot.  Doing this for a class project but I'd also like to be able to leverage this for work.  I have a list of donations that have been made over the course of 4 years.  The most pertinent columns are ID and Year.  I'd like to be able to see which donors have made multiple donations within the same year, and which have made multiple donations over several years.  I imagine it would look something like this:

 

PowerBiExample.JPG

So far I tried the following for the donations within the same year, but it's not quite what I need. It appears to just simply doing a count of donations by ID without taking into account the change in year.

Repeat Within Same Year =
COUNTX(
FILTER(
'Donation_Level',
'Donation_Level'[id]=EARLIER(Donation_Level[id])
),
Donation_Level[Year]
)

Am I better off doing this in the Edit's Query Section (power query?) or in the data section (power pivot?)

 

Any advice would be appreciated.  

 

Thanks!

 

1 ACCEPTED SOLUTION
Zubair_Muhammad
Community Champion
Community Champion

@kdsan

 

Try this calculated column

 

Repeat same YEAR =
VAR mycount =
    CALCULATE (
        COUNTROWS ( Donation_Level ),
        ALLEXCEPT ( Donation_Level, Donation_Level[ID], Donation_Level[Year] )
    )
RETURN
    IF ( mycount > 1, "Y", "N" )

Regards
Zubair

Please try my custom visuals

View solution in original post

4 REPLIES 4
Zubair_Muhammad
Community Champion
Community Champion

@kdsan

 

Try this calculated column

 

Repeat same YEAR =
VAR mycount =
    CALCULATE (
        COUNTROWS ( Donation_Level ),
        ALLEXCEPT ( Donation_Level, Donation_Level[ID], Donation_Level[Year] )
    )
RETURN
    IF ( mycount > 1, "Y", "N" )

Regards
Zubair

Please try my custom visuals

@kdsan

 

And this one

 

Repeat Multiple Years =
VAR mycount =
    CALCULATE (
        DISTINCTCOUNT ( Donation_Level[Year] ),
        ALLEXCEPT ( Donation_Level, Donation_Level[ID] )
    )
RETURN
    IF ( mycount > 1, "Y", "N" )

Regards
Zubair

Please try my custom visuals

@kdsan

 

cbociy.png


Regards
Zubair

Please try my custom visuals

Perfect! Thank you so much!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.