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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
brian0782
Helper II
Helper II

DAX to SUM records based on Quarter Year

Hi

 

I have a Quarter slicer that holds the Quarter Name and Year and I'd like to use the "Year" value to only SUM values for all YoA_Codes <= Period_Year

 

My DAX is below but for some reason I'm not getting the correct result - I'm only expecting to see values for 2003-2020 based on the Quarter slicer value selected - also the SUMs are repeating for each year:

 

brian0782_2-1605882983388.png

 

Can someone advise on where I'm going wrong please?

 

3 REPLIES 3
brian0782
Helper II
Helper II

Hi @amitchandak 

 

I've tried doing this but getting the total repeating across all columns - I'm expecting to see a split by Yoa_Code.

 

Am I missing something?

 

Gross Premium v2 = 
VAR _maxi =
    MAXX ( ALLSELECTED ( period ), VALUE ( Period[period_year] ) )
VAR _maxquarter =
    MAXX ( ALLSELECTED( Period), Period[quarter_name]) 
RETURN
   
        CALCULATE (
            Gross[Gross Premium Total],  
            FILTER ( ALL (AccountYear), AccountYear[yoa_code] <= _maxi),           
            FILTER ( ALL (Period), Period[quarter_name] <= _maxquarter)
        )

brian0782_0-1606127642875.png

 

amitchandak
Super User
Super User

@brian0782 , Try to avoid all selected, unless that is not part of the range. 

 

in with allselected you have add  [year] =max(Year])

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi @amitchandak 

 

Can you clarify where this should be added please?

 

Gross Premium v2 = var _maxi = maxx(allselected(period), VALUE(Period[period_year]))
return
calculate(Gross[Gross Premium Total], filter(ALLSELECTED(AccountYear),AccountYear[yoa_code] <=_maxi))

 

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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