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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
srinivas258
Helper I
Helper I

Running Total Dax help

hello everyone,

I am trying to do basic running total in power bi.  Its based on Stop I have to do the total. Any help/suggestion please on this.

 

stoptotalrunning total
155
238
3614

 

Thank you in advance.

 
6 REPLIES 6
v-alq-msft
Community Support
Community Support

Hi, @srinivas258 

 

Based on your description, I created data to reproduce your scebario.

Table:

b1.png

 

You may create two measures as below.

 

Total = 
var _stop = SELECTEDVALUE('Table'[Stop])
return
SUMX(
    FILTER(
        ALLSELECTED('Table'),
        'Table'[Stop]<=_stop
    ),
    'Table'[Stop]
)

Running Total = 
var _stop = SELECTEDVALUE('Table'[Stop])
var tab = 
ADDCOLUMNS(
    ALLSELECTED('Table'),
    "Total",
    CALCULATE(
        SUM('Table'[Stop]),
        FILTER(
            ALLSELECTED('Table'),
            'Table'[Stop]<= EARLIER('Table'[Stop])
        )
    )
)
var newtab = 
ADDCOLUMNS(
    tab,
    "Runnung Total",
    var t = [Total]
    return
    SUMX(
        FILTER(
            tab,
            [Total] <= t
        ),
        'Table'[Total]
    )
)

return
SUMX(
    FILTER(
        newtab,
        [Stop] = _stop
    ),
    [Runnung Total]
)

 

 

Result:

b2.png

 

I wonder what the column from another table is like and if there is a relationship between two tables.

 

Best Regards

Allan

 

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

 

Hi @v-alq-msft , @amitchandak ,

 

Apologies for not being clear. Stop and Total are from same table. I have an other column (Stop Description) from other table and I would like to add that to this Running Total table. And there is join in place between these two tables. I tried using lookupvalue for had no luck.

Hi, @srinivas258 

 

Could you please show some sample data and the expected result with OneDrive for business? Do mask sensitive data before uploading. Thanks.

 

Best Regards

Allan

amitchandak
Super User
Super User

@srinivas258 ,

Try like

CALCULATE(SUM(Table[Total]),filter(all(Table),Table[stop] <=max(Table[stop])))

Or
CALCULATE(SUM(Table[Total]),filter(allselected(Table),Table[stop] <=max(Table[stop])))

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

Thanks @amitchandak. i tried this and its working CALCULATE(SUM(Table[Total]),filter(allselected(Table),Table[stop] <=max(Table[stop])))

 

but only other problem is if I add an other column (lets say ColumnA) from different table(lets say TableA) it stopped working.

Can you please guide me how I can add that column and table to above formula. 

CheenuSing
Community Champion
Community Champion

Hi @srinivas258 

 

Please check out

 

https://stackoverflow.com/questions/18275270/dax-running-total-or-count-across-2-groups

 

Cheers

 

CheenuSing

Did I answer your question? Mark my post as a solution and also give KUDOS !

Proud to be a Datanaut!

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!

December 2024

A Year in Review - December 2024

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