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
EllenHeijmans1
New Member

Running totals per quarter and year

I need a running total per quarter and year. I've found and expression that helped me to create a measure to calculate a running total per quarter.

 

Running total quarterly =
CALCULATE(SUM('Table'[amount]),FILTER(ALL('Table'),'Table'[Quarter]<=MAX('Table'[Quarter])))

 

But than this is the result:

 

Zucht1.png

as you can see, the totals for 2022 are the same as for 2020. This is because of the fact that the measure only takes the quarter into account.

 

What I want is that the last to lines shows a total of 117 and 118. So I changed the measure as follows:

 

Running total quarterly and yearly =
CALCULATE(
    SUM('Table'[amount]),
    FILTER(
         ALL('Table'),
         'Table'[Quarter]<=MAX('Table'[Quarter]) && 'Table'[Year]<=2022
 
        )
)
 
But it has the same result:
 
How can I display running totals based on quarters over the years?
1 ACCEPTED SOLUTION

Hi @EllenHeijmans1 ,

 

I think you can use YearQuarter as the filter key in your measure. You can try this code to achieve your goal.

Running total quarterly and yearly =
VAR _YearQuarter =
    SELECTEDVALUE ( 'Table'[Year] ) * 100
        + SELECTEDVALUE ( 'Table'[Quarter] )
RETURN
    CALCULATE (
        SUM ( 'Table'[amount] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Year] * 100 + 'Table'[Quarter] <= _YearQuarter
        )
    )

Result is as below.

RicoZhou_0-1664522290722.png

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

4 REPLIES 4
Greg_Deckler
Super User
Super User

@EllenHeijmans1 Better Running Total - Microsoft Power BI Community


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Hi Greg,

 

Thanks for your answer. But unfortunately it doesn't solve my problem.

 

When I use your example I get a beautifull running total, but based on amount and not on a amount per quater. I need a running total per quarter over time. See the image below. So it needs to go from 34, to 58, 79, 106

111, 112.

 

zucht2.png

 

Hi @EllenHeijmans1 ,

 

I think you can use YearQuarter as the filter key in your measure. You can try this code to achieve your goal.

Running total quarterly and yearly =
VAR _YearQuarter =
    SELECTEDVALUE ( 'Table'[Year] ) * 100
        + SELECTEDVALUE ( 'Table'[Quarter] )
RETURN
    CALCULATE (
        SUM ( 'Table'[amount] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Year] * 100 + 'Table'[Quarter] <= _YearQuarter
        )
    )

Result is as below.

RicoZhou_0-1664522290722.png

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Yes!! That works. Thanks Rico.

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.

Top Solution Authors