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
markperrone
Frequent Visitor

Vary the calculated column formula

Not sure which visual will be the most appropriate for this use case.

 

We have a table of various metrics (# of top 20 suppliers, Gross revenue, Shipments, etc) and we're looking to show these metrics for any two months and current YTD.  The month is selectable so the example below could be for Jan-Feb.  Think the 3 columns will be a calculated column with a SWITCH to control which metric is calculated but it didn't work.  Wondering if matrix is the better solution.  Any thoughts are appreciated.  Thanks.

 

MetricMar 2025Apr 2025Jan-Apr 2025
Top 20 suppliers342344347
Gross revenue$10,000,000$11,000,000$13,000,000
Shipments42,00044,00051,000
1 ACCEPTED SOLUTION
DataNinja777
Super User
Super User

Hi @markperrone ,

 

You should use a matrix visual instead of calculated columns because calculated columns are static and do not respond to slicer selections. To show metrics like Top 20 suppliers, Gross revenue, and Shipments across two selected months and YTD, start by reshaping your data into a long format with columns for Metric, Date, and Value. Then, create a single DAX measure:

Metric Value = SUM('MetricsTable'[Value])

In the Date table, create a calculated column that assigns labels like "Month1", "Month2", and "YTD" based on user selections:

Selected Label = 
SWITCH(TRUE(),
    'Date'[Month] = SELECTEDVALUE('MonthSelector'[Month1]), "Month1",
    'Date'[Month] = SELECTEDVALUE('MonthSelector'[Month2]), "Month2",
    'Date'[Date] IN DATESYTD('Date'[Date]), "YTD"
)

Use this new label as the column field in the matrix. Put Metric on the rows, the Selected Label on the columns, and Metric Value as the values. This setup keeps your model dynamic and responsive to slicers. Do not use SWITCH inside a calculated column to try and change metrics—it won’t work because calculated columns are evaluated during data load, not when slicers change. Measures and matrix visuals are designed to handle exactly this kind of flexible layout.

 

Best regards,

View solution in original post

4 REPLIES 4
v-sdhruv
Community Support
Community Support

Hi @markperrone  ,
Just wanted to check if you had the opportunity to review the suggestions provided?
If the response has addressed your query, please accept it as a solution  so other members can easily find it.
Thank You

v-sdhruv
Community Support
Community Support

Hi @markperrone ,
Just wanted to check if you had the opportunity to review the suggestion provided?
If the response has addressed your query, please accept it as a solution  so other members can easily find it.
Thank You

v-sdhruv
Community Support
Community Support

Hi @markperrone ,
Just wanted to check if you had the opportunity to review the suggestion provided?
If the response has addressed your query, please accept it as a solution  so other members can easily find it.
Thank You

DataNinja777
Super User
Super User

Hi @markperrone ,

 

You should use a matrix visual instead of calculated columns because calculated columns are static and do not respond to slicer selections. To show metrics like Top 20 suppliers, Gross revenue, and Shipments across two selected months and YTD, start by reshaping your data into a long format with columns for Metric, Date, and Value. Then, create a single DAX measure:

Metric Value = SUM('MetricsTable'[Value])

In the Date table, create a calculated column that assigns labels like "Month1", "Month2", and "YTD" based on user selections:

Selected Label = 
SWITCH(TRUE(),
    'Date'[Month] = SELECTEDVALUE('MonthSelector'[Month1]), "Month1",
    'Date'[Month] = SELECTEDVALUE('MonthSelector'[Month2]), "Month2",
    'Date'[Date] IN DATESYTD('Date'[Date]), "YTD"
)

Use this new label as the column field in the matrix. Put Metric on the rows, the Selected Label on the columns, and Metric Value as the values. This setup keeps your model dynamic and responsive to slicers. Do not use SWITCH inside a calculated column to try and change metrics—it won’t work because calculated columns are evaluated during data load, not when slicers change. Measures and matrix visuals are designed to handle exactly this kind of flexible layout.

 

Best regards,

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.