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
lokosrio
Helper II
Helper II

Divide sum by total for items where sum is lower than zero

Hi,

 

I have a data like in the table below:

lokosrio_3-1597930016752.png

 

On my chart I want to aggregate them like in the table below:

lokosrio_4-1597930944478.png

1. I want to show only values where the sum < 0
2. Divide the sum/total to present the result as a contribution

3. Be able to filter by other columns

 

Right now I have only DAX which helps me get the elements where the value is bigger than zero:

CALCULATE(SUM('Table'[Measure]),
FILTER(ALL('Table'[Measure]),
SUM('Table'[Measure]) < 0))

 

Could you help me with this, please?

Thank you in advance!

1 ACCEPTED SOLUTION

Hi @lokosrio 

 

could you try to write your measures like this:

Total =
VAR _tmp =
    SUMMARIZE (
        FILTER (
            ADDCOLUMNS (
                CALCULATETABLE ( VALUES ( 'Table'[Dimension 1] ), ALL ( 'Table'[Dimension 1] ) ),
                "t", CALCULATE ( SUM ( 'Table'[Amount] ) )
            ),
            [t] < 0
        ),
        'Table'[Dimension 1]
    )
RETURN
    CALCULATE (
        SUM ( 'Table'[Amount] ),
        FILTER ( ALL ( 'Table'[Dimension 1] ), 'Table'[Dimension 1] IN _tmp )
    )

 

and

 

Contribution = divide(sum('Table'[Amount]),[Total])

 

Cheers,
Sturla

If this post helps, then please consider Accepting it as the solution. Kudos are nice too.

View solution in original post

10 REPLIES 10

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.