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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. 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
    )

 





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.


Click here to visit my LinkedIn page

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
    )

 





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.


Click here to visit my LinkedIn page

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.