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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
djbuncle
Helper I
Helper I

Cumulative Sum With Slicing On Another Dim Attribute

Hi.

I have an issue whereby I've created a running total measure, however I can't slice it on an attribute from another linked dimension.

 

Cumulative Deposits Today:= CALCULATE([Deposit Value], FILTER(ALLEXCEPT(Deposits, Deposits[PlayerId]), Deposits[DepositHour]<= MAX(Deposits[DepositHour])), FILTER('Activity Date',[Today]=TRUE()))

 

Where the PlayerId is the key to a dimension with attributes I want to slice on.

The behaviour is such that any attribute I slice-on form the other dimension gets the same value.

 

On the left shows the calculation working properly. Then on the right we see where I'm slicing on brand which is an attribute from the dimension I link to via the PlayerId I've included in the ALLEXCEPT function. All brands get the same value whereas they each should make up a different proportion of the total.

 

HourCumul. Deposits Today HourBrand ABrand BBrand C
013,658 013,65813,65813,658
121,805 121,80521,80521,805
228,770 228,77028,77028,770
333,861 333,86133,86133,861
437,610 437,61037,610 
541,227 541,22741,227 
644,006 6 44,00644,006
749,388 749,38849,388 
856,043 856,04356,04356,043
961,830 961,83061,83061,830
1068,192 1068,19268,19268,192
1176,907 1176,90776,90776,907
1278,054 1278,05478,05478,054
1378,054 1378,05478,05478,054
1478,054 1478,05478,05478,054
1578,054 1578,05478,05478,054
1678,054 1678,05478,05478,054

 

Any help would be much appreciated.

Cheers

1 ACCEPTED SOLUTION

For the record, I solved this one.

 

I presumed the field to include in the ALLEXCEPT function would be the key to the appropriate dimension (Deposits[PlayerId]) for which I wanted to slice on.

 

Cumulative Deposits Today:= CALCULATE([Deposit Value], FILTER(ALLEXCEPT(Deposits, Deposits[PlayerId]), Deposits[DepositHour]<= MAX(Deposits[DepositHour])), FILTER('Activity Date',[Today]=TRUE()))

 

However what was required was the actual attribute from the related dimension (Player[Brand]). So the downside to this is that you have to list every attribute you want to be able to slice on.

 

Cumulative Deposits Today:= CALCULATE([Deposit Value], FILTER(ALLEXCEPT(Deposits, Player[Brand]), Deposits[DepositHour]<= MAX(Deposits[DepositHour])), FILTER('Activity Date',[Today]=TRUE()))

View solution in original post

5 REPLIES 5
Greg_Deckler
Super User
Super User

Sample data would help tremendously.  Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490


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

Hey Greg. I've added some data in there now... hopefully that makes it a bit clearer.

Hi @djbuncle

You data model is like the following?

8.png

 

6.png7.png

 

Best Regards

maggie

BasicDepositModel.png

 

Here is a simplified image of the data model, where I'm trying to do a cumulative sum of the [DepositAmount] (over the [DepositHour] of the current day). But the slicing by [Brand] from the Player dimension doesn't work properly.

Note I can create a specific measure that filters on the brand, but if I create a generic measure and try to slice in a pivot table, the brands all return the same amount (i.e. it doesn't slice).

For the record, I solved this one.

 

I presumed the field to include in the ALLEXCEPT function would be the key to the appropriate dimension (Deposits[PlayerId]) for which I wanted to slice on.

 

Cumulative Deposits Today:= CALCULATE([Deposit Value], FILTER(ALLEXCEPT(Deposits, Deposits[PlayerId]), Deposits[DepositHour]<= MAX(Deposits[DepositHour])), FILTER('Activity Date',[Today]=TRUE()))

 

However what was required was the actual attribute from the related dimension (Player[Brand]). So the downside to this is that you have to list every attribute you want to be able to slice on.

 

Cumulative Deposits Today:= CALCULATE([Deposit Value], FILTER(ALLEXCEPT(Deposits, Player[Brand]), Deposits[DepositHour]<= MAX(Deposits[DepositHour])), FILTER('Activity Date',[Today]=TRUE()))

Helpful resources

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