Forum Discussion

AnkitKukreja's avatar
AnkitKukreja
Icon for Super User rankSuper User
1 year ago
Solved

Conditional Formatting required for 50 columns

Hi! All, My client requires to compare the data as there has been a system update and the logic has been built, I'm stuck on one of the asks to end this project. I have around 40-50 columns in the v...
  • v-pnaroju-msft's avatar
    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.

    1. 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. 
       

    2. 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.
    3. 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.