cancel
Showing results for 
Search instead for 
Did you mean: 
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
Carousel_PBI_Wave1

2023 Release Wave 1 Plans

Power BI release plans for 2023 release wave 1 describes all new features releasing from April 2023 through September 2023.

Power BI Summit Carousel 2

Global Power BI Training

Make sure you register today for the Power BI Summit 2023. Don't miss all of the great sessions and speakers!

BizApps LATAM 2023

Business Application LATAM Summit 2023

Join the biggest FREE Business Applications Event in LATAM this February.

Power Platform Bootcamp

Global Power Platform Bootcamp

In this bootcamp we will deep-dive into Microsoft’s Power Platform stack with hands-on sessions and labs, delivered to you by experts and community leaders.