Forum Discussion

dennis1994's avatar
dennis1994
Frequent Visitor
8 years ago
Solved

Subtotal in a Row

Hello,

I would like to do something like this:

Day      Label       Hours

01.01       R              2

01.01       I               2

01.01     Total           4

 

I got hours per Day that are split per Label. What I need is the total amount of hours per Day in an extra row. Is that possible?

 

Regards

Dennis

  • Hi dennis1994,

     

    Based on my test, you should be able to follow steps below to get the expected result.

     

    1. Add new table with a single column like below to your model(make sure there is no any relationships between this table and the other tables).

     

     

    2. Use the formula below to create a new measure.

    Measure = 
    VAR lable =
        MAX ( Table2[Label] )
    RETURN
        IF (
            lable = "Total",
            SUM ( Table1[Hours] ),
            CALCULATE ( SUM ( Table1[Hours] ), Table1[Label] = lable )
        )
    

     

    3. Show 'Day' column, 'Lable' column from the new added table, and the measure on Table visual.

     

     

    Here is the sample pbix file for your reference. :smileyhappy:

     

    Regards

2 Replies

  • v-ljerr-msft's avatar
    v-ljerr-msft
    Microsoft Employee

    Hi dennis1994,

     

    Based on my test, you should be able to follow steps below to get the expected result.

     

    1. Add new table with a single column like below to your model(make sure there is no any relationships between this table and the other tables).

     

     

    2. Use the formula below to create a new measure.

    Measure = 
    VAR lable =
        MAX ( Table2[Label] )
    RETURN
        IF (
            lable = "Total",
            SUM ( Table1[Hours] ),
            CALCULATE ( SUM ( Table1[Hours] ), Table1[Label] = lable )
        )
    

     

    3. Show 'Day' column, 'Lable' column from the new added table, and the measure on Table visual.

     

     

    Here is the sample pbix file for your reference. :smileyhappy:

     

    Regards

  • dennis1994's avatar
    dennis1994
    Frequent Visitor

    Hello,

    I would like to do something like this:

    Day      Label       Hours

    01.01       R              2

    01.01       I               2

    01.01     Total           4

     

    I got hours per Day that are split per Label. What I need is the total amount of hours per Day in an extra row. Is that possible?

     

    Regards

    Dennis