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 based on time

I have the following table that I want to use as a running total for an area chart + a matrix visual:

 

TKA_1-1605277156687.png

Additionally, for my table the day doesnt end at 00:00, but after 03:00 am (see last line). I've created an additional column to use the "sort by column" function (along the lines of column = if time < 03:00 then X else X).

 

How do I create a running total based on time? I tried a view solutions from Google results, but none seem to work. Using the quick measure for running total doesnt work either.

 

 

 

 

1 ACCEPTED SOLUTION
v-zhenbw-msft
Community Support
Community Support

Hi @Anonymous ,

 

Are the date and item number column from the same table?

Do you mean creating the slicer like this?

 

R1.jpg

 

If yes, you can try this measure.

 

RT = 
VAR thistime =
    MIN ( 'Table'[Time] )
RETURN
    CALCULATE (
        SUM ( 'Table'[value] ),
        FILTER(
            ALLSELECTED ( 'Table' ),
        'Table'[Time] <= thistime
    ))

 

R2.jpg

 

R3.jpg

 

If it doesn’t meet your requirement, could you please show the exact expected result based on the table that we have shared?

 

Best regards,

 

Community Support Team _ zhenbw

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

 

BTW, pbix as attached.

View solution in original post

5 REPLIES 5
v-zhenbw-msft
Community Support
Community Support

Hi @Anonymous ,

 

Are the date and item number column from the same table?

Do you mean creating the slicer like this?

 

R1.jpg

 

If yes, you can try this measure.

 

RT = 
VAR thistime =
    MIN ( 'Table'[Time] )
RETURN
    CALCULATE (
        SUM ( 'Table'[value] ),
        FILTER(
            ALLSELECTED ( 'Table' ),
        'Table'[Time] <= thistime
    ))

 

R2.jpg

 

R3.jpg

 

If it doesn’t meet your requirement, could you please show the exact expected result based on the table that we have shared?

 

Best regards,

 

Community Support Team _ zhenbw

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

 

BTW, pbix as attached.

Anonymous
Not applicable

Apologies, I should have been more clear. When creating the mockup file I noticed that the measure does indeed work. However, the measure does not take into account my slicers (date and item number right now), which I failed to mention in my opening post. Is there a way to adjust the measure so that slicers are always taken into account? Or how can I manually include this?

v-zhenbw-msft
Community Support
Community Support

Hi @Anonymous ,

 

Do you have a date column? Or just a Time column?

We create a sample and it doesn’t reset on negatives/positives.

 

run1.jpg

 

Could you please provide a mockup sample based on fake data or describe the fields of each tables and the relations between tables simply?

It will be helpful if you can show us the exact expected result based on the tables.

 

Please upload your files to OneDrive For Business and share the link here. Please don't contain any Confidential Information or Real data in your reply.

 

Best regards,

 

Community Support Team _ zhenbw

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

Anonymous
Not applicable

I tried your formula and it seems to be exactly what I was looking for, however, it seems to reset on negatives/positives:

 

TKA_0-1605515721828.png

 

 

mahoneypat
Employee
Employee

Not sure you mean with your sort order column but this measure expression should give you your running total based on time column.

 

RT =
VAR thistime =
    MIN ( Table[TimeColumn] )
RETURN
    CALCULATE (
        SUM ( Table[ValueColumn] ),
        ALLSELECTED ( Table[TimeColumn] ),
        Table[TimeColumn] <= thistime
    )

Replace the table and column names with the actual ones in your model.  Use the measure in a visual with the Time column.

 

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


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.