Reply
msuser48
Helper I
Helper I
Partially syndicated - Outbound

Count rows for each ID and aggregate

I have this sample table:

IdDateProductRunning Total
12017-01-0103
22018-01-0103
32019-01-0103
42017-01-0116
52020-01-0116
62021-01-0116
72021-01-0127
82022-01-0138
92022-01-0149
102017-01-01511
112022-01-01511

 

"Running Total" is a MEASURE (NOT a column), and I need to change this measure such that it works when the date column is filtered.

 

Current code for "Running Total", which generates the above output:

msuser48_0-1670160797214.png

 

Issue with the code: It does not work when the "date" column is filtered using a slicer.

 

I need this output when the date filter is set to 2018-01-01-2023-01-01 for example:

IdDateProductRunning Total
22018-01-0102
32019-01-0102
52020-01-0114
62021-01-0114
72021-01-0125
82022-01-0136
92022-01-0147
112022-01-0158

 

As you can see, 2017 dates are removed, therefore the "Running Total" measure is adjusted accordingly.

 

How to achieve this?

1 ACCEPTED SOLUTION

Syndicated - Outbound

ALLSELECTED did the trick.

View solution in original post

3 REPLIES 3
Greg_Deckler
Super User
Super User

Syndicated - Outbound

@msuser48 You will need to use ALLEXCEPT instead of ALL. Also, this might be of interest: https://community.powerbi.com/t5/Quick-Measures-Gallery/Better-Running-Total/m-p/2755666#M885



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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Syndicated - Outbound

@Greg_Deckler 
can you elaborate how the allexcept should look like? I tried AllExcept(table,product), which still does not work.

Syndicated - Outbound

ALLSELECTED did the trick.

avatar user

Helpful resources

Announcements
March PBI video - carousel

Power BI Monthly Update - March 2025

Check out the March 2025 Power BI update to learn about new features.

March2025 Carousel

Fabric Community Update - March 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors (Last Month)
Top Kudoed Authors (Last Month)