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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Cumulative DAX measure not based on calendar

Hello,

I am trying to write a measure which will yield the incremental totals for a visualisation.

Imagine this table:
Both tables are sorted by the % Pen high to low

Product% Pen
Prod13%
Prod22,8%
Prod31,4%

 

Now I would like to be able to add another column which tells me the incremental contribution of each product.

Here is an example:

Product% PenIncremental % Pen
Prod13%3%
Prod22,8%1,4%
Prod31,4%0,2%

 

The 'Incremental % Pen' column needs to filter away overlapping data between the earlier product and itself as to only present the actual contribution added by the product.

My data model has the following (relevant) tables:

escapethisscree_0-1664193600997.png


I've tried searching for ways to do cumulative/incremental calculations, but what I find seems to be on a table level whereas I need it to be dynamic ie. calculated according to the products selected in the visualisation. I imagine I need a RANKX element to rank based on my [% Pen] measure along with some clever filters but I am in deep here to be quite honest.

I am having a difficult time figuring out how to crack this so please do ask for more info if something is needed. Any help would be much appreciated.

EDIT:
Here is my best attempt so far:

VAR _Rank = RANKX( ALLSELECTED( 'Product'[EAN] ) , CALCULATE( [Penetration] ) )

RETURN
    
    CALCULATE(
        [Penetration],
        TOPN(
            _Rank, 
            ALLSELECTED(
                'Product'[EAN]
            ),
                [Penetration]
)
    )

 

Unfortuneately, I get the same value on every row of my visualisation using this measure:

escapethisscree_0-1664195278790.png

 

 

4 REPLIES 4
Greg_Deckler
Super User
Super User

@Anonymous In your example, where did the 1.4% come from for Prod2 for Incremental? Same question for the .2 for Prod3



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...
Anonymous
Not applicable

@Greg_Deckler 
I'm kind of a rookie and realize that I obviously need to filter away users from my calculation in order to get the 'added contribution' for each product/row evaluated.

I have tried to incorporate this into my measure:

VAR _Rank = RANKX( ALLSELECTED( 'Product'[EAN] ) , CALCULATE( [Penetration] ) )
VAR _User = ALLSELECTED(User[UserId])
VAR _FilteredCalc = CALCULATE(
        [Penetration],
        FILTER(
            'User',
            NOT ( 'User'[UserId] ) IN _User
        )
    )

RETURN
    
    CALCULATE(
        [Penetration],
        TOPN(
            _Rank, 
            ALLSELECTED(
                'Product'[EAN]
            ),
                [Penetration]
)
    )

 

But I will admit there is a decent chance I am trying to solve this in a nonsensical way unfortuneately.

This returns a blank value which I suspect is because my use of ALLSELECTED to select user to filter away is wrong

Anonymous
Not applicable

Thank you for your reply @Greg_Deckler,

I essentially made it up. But it would be the remaining % Pen after filtering away purchases which overlaps each other (User buys both products). I hope this clears it up.

@Anonymous Would need more information, particularly about this overlap. Sorry, having trouble following, can you post sample data as text and expected output?
Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, 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

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.



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

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!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

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