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
ovonel
Post Prodigy
Post Prodigy

custom aggregation in dax?

I have a Project dimension with columns:

  • Level 1:

    • Level 2:

      • Level 3

 

ovonel_0-1669641908163.png

 

 

The aggregarion works fine... Level3, we just display the value, Level2 displays the value only if it is negative... and Level1 is just the sum of Level2

Now, I wanted to add a higher level in the matrix but from Client dimension, I have tried SUMX and it doesn't seem to work. is there a way to achieve it?

 

 

1 ACCEPTED SOLUTION
v-xiaosun-msft
Community Support
Community Support

Hi @ovonel ,

 

According to your description, I wonder whether I understand your requirement correctly, and here is my solution.

Sample data:

vxiaosunmsft_0-1669701814818.png

Create a calculated column to make Level2 display the value only if it is negative.

Column =
VAR _level2 =
    CALCULATE (
        SUM ( 'Tabelle1'[value] ),
        ALLEXCEPT ( Tabelle1, Tabelle1[level2] )
    )
RETURN
    IF ( _level2 > 0, 0, _level2 )

Create a measure to return the final output.

Measure =
SWITCH (
    TRUE (),
    ISINSCOPE ( Tabelle1[level3] ), SUM ( Tabelle1[value] ),
    SUM ( Tabelle1[Column] )
)

Output:

vxiaosunmsft_4-1669702956902.png

Then put a higher level in the matrix, you will get the result below.

vxiaosunmsft_3-1669702913862.png

I attach my sample below for your reference.

 

Best Regards,
Community Support Team _ xiaosun

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-xiaosun-msft
Community Support
Community Support

Hi @ovonel ,

 

According to your description, I wonder whether I understand your requirement correctly, and here is my solution.

Sample data:

vxiaosunmsft_0-1669701814818.png

Create a calculated column to make Level2 display the value only if it is negative.

Column =
VAR _level2 =
    CALCULATE (
        SUM ( 'Tabelle1'[value] ),
        ALLEXCEPT ( Tabelle1, Tabelle1[level2] )
    )
RETURN
    IF ( _level2 > 0, 0, _level2 )

Create a measure to return the final output.

Measure =
SWITCH (
    TRUE (),
    ISINSCOPE ( Tabelle1[level3] ), SUM ( Tabelle1[value] ),
    SUM ( Tabelle1[Column] )
)

Output:

vxiaosunmsft_4-1669702956902.png

Then put a higher level in the matrix, you will get the result below.

vxiaosunmsft_3-1669702913862.png

I attach my sample below for your reference.

 

Best Regards,
Community Support Team _ xiaosun

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.