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
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
)
)

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.