Forum Discussion
Conditional Formatting required for 50 columns
- 1 year ago
Hi AnkitKukreja,
Based on my understanding, to avoid the need for manually creating calculated columns for all 40 to 50 columns, you can utilize a more efficient approach with Power Query and a single dynamic measure.
-
Open Power Query Editor and access it via Transform Data in Power BI Desktop. Add a custom column (for example: HighlightFlag) with a formula such as:
if Text.Contains([Column_Differences], Text.Lower(Text.From([ColumnName]))) then "Highlight" else null
Replace [ColumnName] with the name of the column being evaluated (for instance:ChvTransferPrice). Use Power Query’s Add Column > Custom Column feature and apply this logic across all columns by looping through them.
-
Create a Dynamic Measure.
DynamicHighlight =
IF(
SELECTEDVALUE('Table'[HighlightFlag]) = "Highlight",
1,
0
)In the table visual, apply conditional formatting to all columns. Navigate to the Format pane > Conditional Formatting > Background Color > Field Value > Select DynamicHighlight. Set the value of 1 to your desired highlight color (for example: yellow) and 0 to the default color. -
Test the Visual.Ensure that columns such as ChvTransferPrice are highlighted correctly based on Column_Differences. Save and publish to Microsoft Fabric.
If you find our response helpful, kindly mark it as the accepted solution and provide kudos. This will assist other community members who may be facing similar queries.
Thank you.
-
Hi AnkitKukreja,
Based on my understanding, to avoid the need for manually creating calculated columns for all 40 to 50 columns, you can utilize a more efficient approach with Power Query and a single dynamic measure.
-
Open Power Query Editor and access it via Transform Data in Power BI Desktop. Add a custom column (for example: HighlightFlag) with a formula such as:
if Text.Contains([Column_Differences], Text.Lower(Text.From([ColumnName]))) then "Highlight" else null
Replace [ColumnName] with the name of the column being evaluated (for instance:ChvTransferPrice). Use Power Query’s Add Column > Custom Column feature and apply this logic across all columns by looping through them.
-
Create a Dynamic Measure.
DynamicHighlight =
IF(
SELECTEDVALUE('Table'[HighlightFlag]) = "Highlight",
1,
0
)In the table visual, apply conditional formatting to all columns. Navigate to the Format pane > Conditional Formatting > Background Color > Field Value > Select DynamicHighlight. Set the value of 1 to your desired highlight color (for example: yellow) and 0 to the default color. -
Test the Visual.Ensure that columns such as ChvTransferPrice are highlighted correctly based on Column_Differences. Save and publish to Microsoft Fabric.
If you find our response helpful, kindly mark it as the accepted solution and provide kudos. This will assist other community members who may be facing similar queries.
Thank you.