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
Khalandar
Regular Visitor

Running Total with Matrix(Year of date)

Hi, 

I am new to Power BI. I am facing an issue with Running Total in Matrix visual as below mentioned. 
When I am using single year as 2016, it will giving correct value.

Khalandar_0-1747071427904.png

but once I am using multip years the flow was breaking, as you can see below image 

Khalandar_1-1747071543229.png

here is the dax expression I am using for this 

Khalandar_2-1747071599319.png

can someone help where I am doing wrong
Thanks for advance
Khalandar.

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi, I am not sure how your semantic model looks like, but if you are looking for the selected years rank, please check the below picture and the attached pbix file.

I think, please correct me if I am wrong, in each year, the ranking of cities are different. If you want to rank the cities for all selected years, please check the below. 
Window DAX function is used in the measure.

Jihwan_Kim_1-1747087620307.png

 

 

Jihwan_Kim_0-1747087569807.png

 

WINDOW function (DAX) - DAX | Microsoft Learn

 

total sales: = 
SUM( orders_fact[sales] )

 

cumulative sales: = 
VAR _cumulate =
    WINDOW (
        1,
        ABS,
        0,
        REL,
        ALL ( city_dimension[city] ),
        ORDERBY (
            CALCULATE (
                [total sales:],
                ALLSELECTED ( year_dimension[year] )
            ), DESC
        )
    )
RETURN
    CALCULATE (
        [total sales:],
        _cumulate
    )

 





 

    Microsoft MVP




If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.





LinkedIn
Visit my LinkedIn page





Outlook Booking
Schedule a short Teams meeting to discuss your question.




View solution in original post

1 REPLY 1
Jihwan_Kim
Super User
Super User

Hi, I am not sure how your semantic model looks like, but if you are looking for the selected years rank, please check the below picture and the attached pbix file.

I think, please correct me if I am wrong, in each year, the ranking of cities are different. If you want to rank the cities for all selected years, please check the below. 
Window DAX function is used in the measure.

Jihwan_Kim_1-1747087620307.png

 

 

Jihwan_Kim_0-1747087569807.png

 

WINDOW function (DAX) - DAX | Microsoft Learn

 

total sales: = 
SUM( orders_fact[sales] )

 

cumulative sales: = 
VAR _cumulate =
    WINDOW (
        1,
        ABS,
        0,
        REL,
        ALL ( city_dimension[city] ),
        ORDERBY (
            CALCULATE (
                [total sales:],
                ALLSELECTED ( year_dimension[year] )
            ), DESC
        )
    )
RETURN
    CALCULATE (
        [total sales:],
        _cumulate
    )

 





 

    Microsoft MVP




If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.





LinkedIn
Visit my LinkedIn page





Outlook Booking
Schedule a short Teams meeting to discuss your question.




Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

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.