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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
sekic
Helper I
Helper I

Measure with conditional sum or percentage

I try to get percentage of totals, but matrix show total all percentage.

Matrix show total Revenue, Expenses, Profit and percent of profit over revenue.

Can't find any idea how to form measure with condition to avoid sumimg percentages.

 

Category Name        Dept    Total
1        Revenue             1200
                     D1       700
                     D2       500
2        Exp                 1000
                     D1       800
                     D2       200
3        Profit               200
                     D1      -100
                     D2       300
4        Profit %            45.7 there is sum(-14.3+60.0)
                                  instead 16.7% as Profit % of total profit

                                  over total Revenue (as 200/1200)
                     D1     -14.3 (as -100/700)
                     D2      60.0 (as 300/500)

1 ACCEPTED SOLUTION
v-yulgu-msft
Employee
Employee

Hi @sekic,

 

The "Total" column in Matrix sums up detailed records per row group, it is not able to change this default behavior to make it do a different calculation for some specific groups.

 

As a workaround, you can try this measure:

Total = SUM(Test4[Amount])

Sub total =
IF (
    SELECTEDVALUE ( Test4[Name] ) = "Profit%",
    CALCULATE (
        SUM ( Test4[Amount] ),
        FILTER ( ALL ( Test4 ), Test4[Name] = "Profit" )
    )
        / CALCULATE (
            SUM ( Test4[Amount] ),
            FILTER ( ALL ( Test4 ), Test4[Name] = "Revenue" )
        ),
    CALCULATE ( SUM ( Test4[Amount] ), ALL ( Test4[Dept] ) )
)

1.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
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-yulgu-msft
Employee
Employee

Hi @sekic,

 

The "Total" column in Matrix sums up detailed records per row group, it is not able to change this default behavior to make it do a different calculation for some specific groups.

 

As a workaround, you can try this measure:

Total = SUM(Test4[Amount])

Sub total =
IF (
    SELECTEDVALUE ( Test4[Name] ) = "Profit%",
    CALCULATE (
        SUM ( Test4[Amount] ),
        FILTER ( ALL ( Test4 ), Test4[Name] = "Profit" )
    )
        / CALCULATE (
            SUM ( Test4[Amount] ),
            FILTER ( ALL ( Test4 ), Test4[Name] = "Revenue" )
        ),
    CALCULATE ( SUM ( Test4[Amount] ), ALL ( Test4[Dept] ) )
)

1.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

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