Forum Discussion

tsunamisabella's avatar
tsunamisabella
Frequent Visitor
3 years ago
Solved

Create a dynamic column subtotal measure

Hello! I want create a measure [Subtotal] to retrieve the column subtotal (subtotal of the selected period) which can be dyanically changed along the selected column dimension [Period]. Note that [Period] is both the column dimension and a filter.

 

I created a measure below, however, in the pivot table, this [Subtotal] returns the grand total, instead of column subtotal per customer segment:

 

Subtotal = CALCULATE(
[a_measure],
ALLEXCEPT(table_name, table_name[Period])
)

 

 

 

[Period]2023-01 2023-02 2023-03  
[Customer]ValueSubtotalValueSubtotalValueSubtotalColumn Subtotal
Segment 11151151153
Segment 22152152156
Segment 33153153159
Segment 441541541512
Segment 551551551515

 

My goal it to have:

(1)  the measure summarize the column subtotal at each row dimension

[Period]2023-01 2023-02 2023-03  
[Customer]ValueSubtotalValueSubtotalValueSubtotalColumn Subtotal
Segment 11313133
Segment 22626266
Segment 33939399
Segment 441241241212
Segment 551551551515

(2) subtotal chanegs along [Period] selected, for exmaple, if I unselect 2023-03, the following table should return correct value:

[Period]2023-01 2023-02
[Customer]ValueSubtotalValueSubtotalColumn Subtotal
Segment 112122
Segment 224244
Segment 336366
Segment 448488
Segment 551051010

 

Can you help me correct my measure? Thank you in advance!

2 Replies

  • tamerj1's avatar
    tamerj1
    Community Champion

    Hi tsunamisabella 

    Please try

    Subtotal =
    CALCULATE ( [a_measure], ALLSELECTED ( table_name[Period] ) )
    • tsunamisabella's avatar
      tsunamisabella
      Frequent Visitor

      OMG! Thank you for the swift reply and the simply & wonderful solution 🥰!