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
msuser48
Helper I
Helper I

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

ALLSELECTED did the trick.

View solution in original post

3 REPLIES 3
Greg_Deckler
Super User
Super User

@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


@ 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...

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

ALLSELECTED did the trick.

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.