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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Running total

Hello all,

 

I've this running total measure:

 

Running Total Ferien Rest =

CALCULATE(
SUM(DIA_SAP_ABSENZEN[Ferien Rest]),
FILTER(
ALLSELECTED(DIA_SAP_ABSENZEN),
DIA_SAP_ABSENZEN[Datum] <= MAX(DIA_SAP_ABSENZEN[Datum])
)
)
 
It gives me the correct running total up to a specific date, or within a specific date range, which is good.
 
However, now I need it to give me the running total for up to any given date, or a date range, which will also include all data since inception. For example, if I choose 2020, then I'd like the remaining balance from 2019/18/17 etc to be icluded, whilst at the moment it only gives me the running total for 2020.
 
Is this doable with this measure, or should I use something else?
1 ACCEPTED SOLUTION
AlB
Super User
Super User

@Anonymous 

I see that you're using the Date table fields for slicing. That's much better. Try this:

Measure V4 = 
VAR max_ =
    MAX ( 'Date'[Date] )
RETURN
    CALCULATE ( SUM ( Table1[Ferien Rest] ), 'Date'[Date] <= max_, ALL ( 'Date' ) )

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

 

View solution in original post

11 REPLIES 11
Anonymous
Not applicable

Hi @AlB 

 

V4 did the trick. Thanks very much!

 

I've another complicated question. I'll run it by you on a private message before posting it in the open.

AlB
Super User
Super User

@Anonymous 

I see that you're using the Date table fields for slicing. That's much better. Try this:

Measure V4 = 
VAR max_ =
    MAX ( 'Date'[Date] )
RETURN
    CALCULATE ( SUM ( Table1[Ferien Rest] ), 'Date'[Date] <= max_, ALL ( 'Date' ) )

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

 

Anonymous
Not applicable

Hi @AlB 

 

Thank you for the new measure!

 

It works as far as filtering by colleague-name is concerned:

 

Nigel_Mayhew_0-1606980186904.png

 

However, the moment I start filtering using the dates slicers.

 

The year filter for 2020 brings 0, when it should be 50.30:

 

Nigel_Mayhew_1-1606980423904.png

 

And, when I add Q4 to the filter, it's -58.80, when it should be 50.30:

 

Nigel_Mayhew_2-1606980567087.png

 

Can you please help with fixing the measure?

 

I've now updated the .pbix file on the Drive: https://drive.google.com/file/d/1I0mTOcldE0oLSKKFI_iyvYgUMKjPmtKG/view?usp=sharing

 

I look forward to hearing back from you.

 

Cheers.

 

 

AlB
Super User
Super User

@Anonymous 

MeasureV3 =
CALCULATE (
    SUM ( Table1[Ferien Rest] ),
    FILTER ( ALLSELECTED ( Table1 ), Table1[Datum] <= MAX ( Table1[Datum] ) )
)

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

 

Anonymous
Not applicable

Hi @AlB 

 

Thanks for your answer.

 

Unfortunately, its still doesn't work. It gives the wrong total, the moment I filter on the colleague-name, even without applying any date filters from the slicers (the running balance should be 50.3):

 

Nigel_Mayhew_0-1606925660102.png

 

 

Any other suggestions please?

AlB
Super User
Super User

@Anonymous 

Perhaps I have misunderstood but this is very simple:

Measure V2 =
CALCULATE (
    SUM ( Table1[Ferien Soll] ),
    FILTER ( ALL ( Table1 ), Table1[Datum] <= MAX ( Table1[Datum] ) )
)

This will give you the cumulative value from the beginning of time up to the max date selected with the slicer. Do note that setting the slicers up like you have, quarter, month, week, etc all separately, you can have any kind of combination in the slicers. It is recommened to use a date table for the slicers instead of the date columns in the fact table. You have the date table already in the model; use it      

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

Anonymous
Not applicable

Hi @AlB and @amitchandak 

 

You can find the file here: https://drive.google.com/file/d/1I0mTOcldE0oLSKKFI_iyvYgUMKjPmtKG/view?usp=sharing

 

Looking forward to your feedback.

 

Many thanks.

Anonymous
Not applicable

Hi @AlB and @amitchandak 

 

How can I share/attach the .pbix file? I tried to attach it to this message, but it say it is not supported.

 

Thanks.

AlB
Super User
Super User

@Anonymous 

It will be difficult to fix without the pbix. Can you share it? Or a version with mock data that repoduces the issue?

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

Anonymous
Not applicable

Hi @amitchandak 

 

Thanks for your response.

 

Unfortunately it didn't work. 

 

- When I don't use any slicer filters at all, then it gives me a number slightly lower than what it should be, and it doesn't seem to correspond to any totals I can glean from my data:

Nigel_Mayhew_2-1606907390256.png

 

 

- When I apply a filter for 2020, then I get a smaller figure than what it should be, and it still doesn't correspond to my totals:

Nigel_Mayhew_3-1606908043216.png

 

- When I filter on a colleague name, then I get a huge number, unrelated to anything I have:

Nigel_Mayhew_0-1606907055024.png

 

Could you please look into it?

amitchandak
Super User
Super User

@Anonymous , Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Try like

 

Running Total Ferien Rest =

var _max = maxx(allselected(DIA_SAP_ABSENZEN),DIA_SAP_ABSENZEN[Datum])

return
CALCULATE(
SUM(DIA_SAP_ABSENZEN[Ferien Rest]),
FILTER(
ALL(DIA_SAP_ABSENZEN),
DIA_SAP_ABSENZEN[Datum] <= MAX(DIA_SAP_ABSENZEN[Datum])

&& DIA_SAP_ABSENZEN[Datum] < _max
)
)

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.