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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Dunner2020
Post Prodigy
Post Prodigy

Calculate percentage of selected year

Hi there,

 

I am trying to calculate the percentage of events that occurred at a location. I want to calculate the percentage in such a way that if I select the year from the slicer then it gives me the percentage of events that occurred in the selected year. If nothing is selected then it gives a percentage of all years. 

 

I am calculating measure something like that:

 

No of events = CALCULATE( DISTINCTCOUNT('Main Table'[OutageID]), FILTER('Main Table', 'Main Table'[Actual Interruption Start Time (NZST)] <= Today()))
Percentage =
Var _total_events = CALCULATE([No of events],ALLEXCEPT('Date','Date'[RY Year]))
Return
CALCULATE(([No of events] / _total_events)*100)
 
However, I got the following output
 
leo_89_0-1622421267275.png

Could anyone help me where I made the mistake?

Sample file here

 

1 ACCEPTED SOLUTION
CNENFRNL
Community Champion
Community Champion

# Events = DISTINCTCOUNT( 'Main Table'[OutageID] )
Pct = 
DIVIDE(
    [# Events],
    CALCULATE( [# Events], ALLEXCEPT( 'Main Table', 'Date'[RY] ) )
)

Screenshot 2021-05-31 035943.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

1 REPLY 1
CNENFRNL
Community Champion
Community Champion

# Events = DISTINCTCOUNT( 'Main Table'[OutageID] )
Pct = 
DIVIDE(
    [# Events],
    CALCULATE( [# Events], ALLEXCEPT( 'Main Table', 'Date'[RY] ) )
)

Screenshot 2021-05-31 035943.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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