Forum Discussion

techhelp's avatar
techhelp
New Member
7 months ago
Solved

Conditional formatting rows based on blank values in the grand total column with matrix visuals

I have a matrix visual and I turned on the grand total column setting. I want to create a conditional formatting rule that will highlight all rows where the grand total column value is blank. 

  • This is a very common Matrix + Grand Total + Conditional Formatting challenge in Power BI. Let’s solve it cleanly and the right DAX way.
    Step 1 – Create a helper measure to detect blank Grand Total
    Assume your main measure is: [Total Sales]
    Create a new measure:
    Row Highlight Flag =
    VAR GrandTotalValue =
    CALCULATE(
    [Total Sales],
    REMOVEFILTERS( 'Date' ) -- replace with your column used in Columns of matrix
    )
    RETURN
    IF(
    ISBLANK( GrandTotalValue ),
    1,
    0
    )

     

    Why this works?

    • REMOVEFILTERS() forces DAX to calculate Grand Total for that row
    • If it’s BLANK(), the row qualifies for formatting

    Step 2 – Apply Conditional Formatting

    1. Select your Matrix visual
    2. Go to Values → Conditional formatting
    3. Choose:
      • Background color (or Font color)
    4. Select:
      • Format by → Rules
      • Based on field → Row Highlight Flag
    5. Rule setup:
      • If value is 1
      • Apply your highlight color (e.g., light red or yellow)

    This will highlight the entire row, not just one cell.

     

    Common Mistakes to Avoid
    Using   ISBLANK([Total Sales])   directly
    >> That only checks cell-level, not Grand Total

    Formatting based on the value column itself
    >> Won’t work for row-level logic

     

    =================================================================
    Did I answer your question? Mark my post as a solution! This will help others on the forum!

    Appreciate your Kudos!!

    Jaywant Thorat | MCT | Data Analytics Coach
    LinkedIn: https://www.linkedin.com/in/jaywantthorat/
    Join #MissionPowerBIBharat = https://shorturl.at/5ViW9
    #MissionPowerBIBharat
    LIVE with Jaywant Thorat from 10 Jan 2026
    8 Days | 8 Sessions | 1 hr daily | 100% Free

  •  

    This is doable, but there’s one important limitation: Power BI does not let you directly reference the Grand Total column in conditional formatting. You have to re-create the same logic in a measure and use that measure for formatting.


    Step 1: Create a measure that returns the grand total value :-

    Grand Total Value = CALCULATE([YourValueMeasure],REMOVEFILTERS( 'YourColumnField' ))

     

    Replace 'YourColumnField' with the field used in Columns of the matrix.

    Step 2: Create a flag measure for formatting :-

    Highlight Blank Grand Total =
    IF(ISBLANK( [Grand Total Value] ),1,0)

    Step 3: Apply conditional formatting

    1. Select the matrix

    2. Go to Format - Conditional formatting

    3. Choose Background color (or Font color)

    4. Format by: Rules (or Field value)

    5. Base it on: Highlight Blank Grand Total

    6. Rule:

      • If value = 1 - set highlight color

      • Else - no color

8 Replies

  • Hi techhelp 

    You can create a measure yourself that replicates the grand total column (Can't help with the DAX since I do not know what is in your matrix) and use this measure to drive the conditional formatting.
    You will need to set up conditional formatting for each column in your matrix separately, as it is not possible to format entire rows at once.

    Let me know if you have any questions.

  • 1) Assume this setup

    • Matrix Rows: e.g. Dim[RowName]

    • Matrix Columns: e.g. Dim[Month]

    • Matrix Values: [Your Measure]

    • Column Grand Total is ON

     

    2) Create a helper measure to detect “blank grand total”

    Is Blank Grand Total =
    VAR GrandTotalValue =
        CALCULATE (
            [Your Measure],
            REMOVEFILTERS ( 'Dim'[RpwName] )
        )
    RETURN
    IF ( ISBLANK ( GrandTotalValue ), 1, 0 )
     
    3) Create a color (or flag) measure
    Row Highlight Color =
    IF ( [Is Blank Grand Total] = 1, "#FFF2CC", BLANK() )

     

    4) Apply conditional formatting

    1. Select the Matrix

    2. Values → Conditional formatting

    3. Choose:

      • Background color (or Font color)

    4. Format by: Field value

    5. Based on field: Row Highlight Color

  • This is a very common Matrix + Grand Total + Conditional Formatting challenge in Power BI. Let’s solve it cleanly and the right DAX way.
    Step 1 – Create a helper measure to detect blank Grand Total
    Assume your main measure is: [Total Sales]
    Create a new measure:
    Row Highlight Flag =
    VAR GrandTotalValue =
    CALCULATE(
    [Total Sales],
    REMOVEFILTERS( 'Date' ) -- replace with your column used in Columns of matrix
    )
    RETURN
    IF(
    ISBLANK( GrandTotalValue ),
    1,
    0
    )

     

    Why this works?

    • REMOVEFILTERS() forces DAX to calculate Grand Total for that row
    • If it’s BLANK(), the row qualifies for formatting

    Step 2 – Apply Conditional Formatting

    1. Select your Matrix visual
    2. Go to Values → Conditional formatting
    3. Choose:
      • Background color (or Font color)
    4. Select:
      • Format by → Rules
      • Based on field → Row Highlight Flag
    5. Rule setup:
      • If value is 1
      • Apply your highlight color (e.g., light red or yellow)

    This will highlight the entire row, not just one cell.

     

    Common Mistakes to Avoid
    Using   ISBLANK([Total Sales])   directly
    >> That only checks cell-level, not Grand Total

    Formatting based on the value column itself
    >> Won’t work for row-level logic

     

    =================================================================
    Did I answer your question? Mark my post as a solution! This will help others on the forum!

    Appreciate your Kudos!!

    Jaywant Thorat | MCT | Data Analytics Coach
    LinkedIn: https://www.linkedin.com/in/jaywantthorat/
    Join #MissionPowerBIBharat = https://shorturl.at/5ViW9
    #MissionPowerBIBharat
    LIVE with Jaywant Thorat from 10 Jan 2026
    8 Days | 8 Sessions | 1 hr daily | 100% Free

  •  

    This is doable, but there’s one important limitation: Power BI does not let you directly reference the Grand Total column in conditional formatting. You have to re-create the same logic in a measure and use that measure for formatting.


    Step 1: Create a measure that returns the grand total value :-

    Grand Total Value = CALCULATE([YourValueMeasure],REMOVEFILTERS( 'YourColumnField' ))

     

    Replace 'YourColumnField' with the field used in Columns of the matrix.

    Step 2: Create a flag measure for formatting :-

    Highlight Blank Grand Total =
    IF(ISBLANK( [Grand Total Value] ),1,0)

    Step 3: Apply conditional formatting

    1. Select the matrix

    2. Go to Format - Conditional formatting

    3. Choose Background color (or Font color)

    4. Format by: Rules (or Field value)

    5. Base it on: Highlight Blank Grand Total

    6. Rule:

      • If value = 1 - set highlight color

      • Else - no color

  • techhelp 

     

    Measure for Grand Total check:

    Row Has Data = 
    IF(
    ISINSCOPE(YourRowField1) && ISINSCOPE(YourRowField2),
    NOT(ISBLANK([YourMeasure])),
    NOT(ISBLANK([YourMeasure]))
    )

    Conditional formatting:

    Values field → Conditional formatting → Background color

    Format by: Field value → Select [Row Has Data]

    Apply to: Values and totals

    Rule: = TRUE → Red background

     

    If this answer helped, please click 👍 or Accept as Solution.
    -Kedar
    LinkedIn: https://www.linkedin.com/in/kedar-pande

  •   

    Check: https://learn.microsoft.com/en-gb/power-bi/create-reports/desktop-conditional-table-formatting for details.

     

    You can do simple as 

     

    But if you want only for grand totals and not intermediate totals, 
    Create a measure as
    Grand Total Color =
    IF(
    ISFILTERED(YourTable[YourColumn]) && ISINSCOPE(YourTable[YourColumn]) && MIN(YourTable[YourColumn]) = MAX(YourTable[YourColumn]), // Detects grand total
    "Red", // Color for grand total
    "White" // Default color
    )

    • Select your Matrix visual.
    • Go to the Visualizations pane, find the measure you want to format (e.g., Sum of Sales), click the down arrow, and select Conditional formatting > Background color (or Font color, etc.).
    • In the advanced controls dialog, set Format style to "Field value".
    • For "What field should we base this on?", select the color measure you just created (e.g., Grand Total Color).
    • Crucially, in the "Apply to" dropdown, select "Values and Totals" to ensure the formatting applies to both regular cells and grand totals. 



  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi techhelp,

     

    Thank you for reaching out to the Microsoft Fabric Forum Community, and special thanks to cengizhanarslan , Jaywant-Thorat , Amar_Kumar and Kedar_Pande  for prompt and helpful responses.

    Just following up to see if the Response provided by community members were helpful in addressing the issue. if the issue still persists Feel free to reach out if you need any further clarification or assistance.

     

    Best regards,
    Prasanna Kumar

     

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi @techhelp,

     

    Just following up to see if the Response provided by community members were helpful in addressing the issue. if the issue still persists Feel free to reach out if you need any further clarification or assistance.

     

    Best regards,
    Prasanna Kumar