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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Laxman222
Regular Visitor

Dynamic columns changing according to time intelligence

I have use case where  I need double headers such as MTD, YTD and under that I need to have sales,order count, margin and for YTD it shouldn't calculate order count. Any solution for this.

1 ACCEPTED SOLUTION
OwenAuger
Super User
Super User

Hi @Laxman222 

Method 1: A general technique I've used in the past is:

  1. Create a calculation group ("Measure") for measure selection (to allow measures to be "hidden")
  2. Create another calculation group ("Measure Visibility") with a calculation item that blanks out certain combinations of measure/time intelligence (in your case "Order Count"/"YTD".
  3. Apply the calculation item from step 2 as a filter on the visual.

Example PBIX attached for you to take a look.

 

Here is the DAX script for the Measure and Measure Visibility calculation groups in my example:

 

-------------------------------
-- Calculation Group: 'Measure'
-------------------------------
CALCULATIONGROUP 'Measure'[Measure]    , Precedence = 1

    CALCULATIONITEM "Sales" = [Sales]
        , FormatString = "#,0"
        , Ordinal = 0

    CALCULATIONITEM "Margin" = [Margin]
        , FormatString = "#,0.00"
        , Ordinal = 1

    CALCULATIONITEM "Order Count" = [Order Count]
        , FormatString = "#,0"
        , Ordinal = 1

------------------------------------------
-- Calculation Group: 'Measure Visibility'
------------------------------------------
CALCULATIONGROUP 'Measure Visibility'[Measure Visibility]    , Precedence = 2

    CALCULATIONITEM "Exclude Order Count YTD" = 
        VAR CurrentMeasure =
            SELECTEDVALUE ( 'Measure'[Measure] )
        VAR CurrentTimeCalc =
            SELECTEDVALUE ( 'Time Intelligence'[Time Calc] )
        VAR Result =
            IF (
                NOT ( CurrentMeasure = "Order Count" && CurrentTimeCalc = "YTD" ),
                SELECTEDMEASURE ()
            )
        RETURN
            Result
        , FormatString = SELECTEDMEASUREFORMATSTRING ()

 

OwenAuger_0-1726642553826.png

Method 2: Another (possibly simpler) method is to use the Hierarchy Slicer custom visual to select the desired combinations of Time Intelligence and Measure calculation items. The Hierarchy Slicer will work if a blank measure is placed on it (or you could use another suitable measure).

OwenAuger_0-1726643204334.png

 

Well these are a couple of possible approaches. Would something like these work in your case?

 

Regards


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

View solution in original post

2 REPLIES 2
Laxman222
Regular Visitor

It worked for me

OwenAuger
Super User
Super User

Hi @Laxman222 

Method 1: A general technique I've used in the past is:

  1. Create a calculation group ("Measure") for measure selection (to allow measures to be "hidden")
  2. Create another calculation group ("Measure Visibility") with a calculation item that blanks out certain combinations of measure/time intelligence (in your case "Order Count"/"YTD".
  3. Apply the calculation item from step 2 as a filter on the visual.

Example PBIX attached for you to take a look.

 

Here is the DAX script for the Measure and Measure Visibility calculation groups in my example:

 

-------------------------------
-- Calculation Group: 'Measure'
-------------------------------
CALCULATIONGROUP 'Measure'[Measure]    , Precedence = 1

    CALCULATIONITEM "Sales" = [Sales]
        , FormatString = "#,0"
        , Ordinal = 0

    CALCULATIONITEM "Margin" = [Margin]
        , FormatString = "#,0.00"
        , Ordinal = 1

    CALCULATIONITEM "Order Count" = [Order Count]
        , FormatString = "#,0"
        , Ordinal = 1

------------------------------------------
-- Calculation Group: 'Measure Visibility'
------------------------------------------
CALCULATIONGROUP 'Measure Visibility'[Measure Visibility]    , Precedence = 2

    CALCULATIONITEM "Exclude Order Count YTD" = 
        VAR CurrentMeasure =
            SELECTEDVALUE ( 'Measure'[Measure] )
        VAR CurrentTimeCalc =
            SELECTEDVALUE ( 'Time Intelligence'[Time Calc] )
        VAR Result =
            IF (
                NOT ( CurrentMeasure = "Order Count" && CurrentTimeCalc = "YTD" ),
                SELECTEDMEASURE ()
            )
        RETURN
            Result
        , FormatString = SELECTEDMEASUREFORMATSTRING ()

 

OwenAuger_0-1726642553826.png

Method 2: Another (possibly simpler) method is to use the Hierarchy Slicer custom visual to select the desired combinations of Time Intelligence and Measure calculation items. The Hierarchy Slicer will work if a blank measure is placed on it (or you could use another suitable measure).

OwenAuger_0-1726643204334.png

 

Well these are a couple of possible approaches. Would something like these work in your case?

 

Regards


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.