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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
LP280388
Resolver II
Resolver II

running total showing wrong Total

Hi Team,

 

I have a measure as below to calculate the running total of IDs. however I see a strange wrong total issue as highlighted below. Please help me what resolve this issue. 

 

For 04/09/2022 to 04/12/2022 it should show 17220 as Running total instead of 17219.

 

Measure : 

Running Total=

var maxdate = Max('data'[DATE])

return CALCULATE(COUNT('data'[ID]),ALL('data'[DATE]),'data'[status]="Completed",'data'[DATE] <= maxdate

 

 

LP280388_1-1700068222092.png

 

 

1 ACCEPTED SOLUTION

Hi @LP280388 ,

 

I did simple samples as it might be a bit difficult to write more than 10,000 data so I used sum instead of count and you can check the result as below:

vtianyichmsft_0-1700199989010.png

Running Total = 
var _t = ADDCOLUMNS('Table',"Total",SUMX(FILTER(ALL('Table'),[DATE]<=EARLIER([DATE])&&[status]="Completed"),'Table'[ID]))
return 
SUMX(_t,[Total])

You can simply change it to suit your needs.

 

An attachment for your reference. Hope it helps!

 

Best regards,
Community Support Team_ Scott Chang

 

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

7 REPLIES 7
AmiraBedh
Resident Rockstar
Resident Rockstar

Can you try the following : 

 

Running Total =
VAR maxdate = MAX('data'[DATE])
RETURN
    CALCULATE(
        COUNT('data'[ID]),
        FILTER(
            ALL('data'),
            'data'[DATE] <= maxdate && 'data'[status] = "Completed"
        )
    )

 

I used FILTER(ALL('data'), ...) instead of ALL('data'[DATE])to ensure that all filters are removed from the entire data table but keeps the logic that checks the date and status.


Proud to be a Power BI Super User !

Microsoft Community : https://docs.microsoft.com/en-us/users/AmiraBedhiafi
Linkedin : https://www.linkedin.com/in/amira-bedhiafi/
StackOverflow : https://stackoverflow.com/users/9517769/amira-bedhiafi
C-Sharp Corner : https://www.c-sharpcorner.com/members/amira-bedhiafi
Power BI Community :https://community.powerbi.com/t5/user/viewprofilepage/user-id/332696

Hi Thanks for your reply. I tried but no change in the result.  I did try Quick Measure > Running Total.   This also gives the same result.

Can you share your pbix file ?


Proud to be a Power BI Super User !

Microsoft Community : https://docs.microsoft.com/en-us/users/AmiraBedhiafi
Linkedin : https://www.linkedin.com/in/amira-bedhiafi/
StackOverflow : https://stackoverflow.com/users/9517769/amira-bedhiafi
C-Sharp Corner : https://www.c-sharpcorner.com/members/amira-bedhiafi
Power BI Community :https://community.powerbi.com/t5/user/viewprofilepage/user-id/332696

Sorry I may not be able to share the file at this point. However, I would like to mention, there is a filter on the page level from another table.  that filter is filtering out Invalid employees.  

do you think that has any effect on this issue?

 

Hi @LP280388 ,

 

I did simple samples as it might be a bit difficult to write more than 10,000 data so I used sum instead of count and you can check the result as below:

vtianyichmsft_0-1700199989010.png

Running Total = 
var _t = ADDCOLUMNS('Table',"Total",SUMX(FILTER(ALL('Table'),[DATE]<=EARLIER([DATE])&&[status]="Completed"),'Table'[ID]))
return 
SUMX(_t,[Total])

You can simply change it to suit your needs.

 

An attachment for your reference. Hope it helps!

 

Best regards,
Community Support Team_ Scott Chang

 

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

 

@LP280388 It's a single table data model, CALCULATE is not going to work. You need to use the No CALCULATE approach below. I made a video on this exact topic:


Follow on LinkedIn
@ 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...

Maybe. You can still send me by message the file.


Proud to be a Power BI Super User !

Microsoft Community : https://docs.microsoft.com/en-us/users/AmiraBedhiafi
Linkedin : https://www.linkedin.com/in/amira-bedhiafi/
StackOverflow : https://stackoverflow.com/users/9517769/amira-bedhiafi
C-Sharp Corner : https://www.c-sharpcorner.com/members/amira-bedhiafi
Power BI Community :https://community.powerbi.com/t5/user/viewprofilepage/user-id/332696

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.