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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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


@ 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!:
Mastering Power BI 2nd Edition

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.


@ 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!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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