Forum Discussion

AlissaStuart's avatar
AlissaStuart
Regular Visitor
9 months ago
Solved

Edit Table with Calculation Items

Hello Everyone, 
I have a table where all of the rows are Calulation Items. So Job Stars is One Calc.item, Job Starrd YouthHSN in onther Calc. Item, etc.  Each Caculated Item is equal to a unique measure.
I want to to color the rows so it's easies to see subgroups in the table (eg brlow)

 

Does anyone know how to do it?
I think maybe I can set a colout into each measure. 
For example this is my measure is

Job Starts =
CALCULATE(
    DISTINCTCOUNT('XX'[Plan Item ID]),
    FILTER('XX',
    'XX'[Working] = "yes")
)

Anyway I can add a colour code to this measure?
Thanks 

  • Anonymous's avatar
    Anonymous
    9 months ago

    Hi AlissaStuart ,

    Thank you for reaching out to Microsoft fabric community forum.

     

    Since your rows are generated from a calculation group, the Matrix can't directly apply color to the row headers. However, you can still achieve clear row banding by coloring the values according to the calculation item in each row. To do this, create a simple color measure that checks the selected calc item (using SELECTEDVALUE('Calc Group'[Name])) and returns a hex color with a SWITCH statement, assigning each item or subgroup a specific color. To handle totals, use IF(NOT ISINSCOPE('Calc Group'[Name]), BLANK(), <color>). Then, in the Matrix, use Conditional formatting - Background color - Field value and select this color measure for the Values/Totals. This will shade each data row by calc item, giving you the subgroup highlights you want without changing your calc group setup. If you have many items, consider adding a [Subgroup] column to the calc group table and use it in your SWITCH to keep color assignments organized.

    Create calculation groups in Power BI - Power BI | Microsoft Learn

     

    Hope this helps. Please reach out for further assistance.

    Thank you.

7 Replies

  • Hi, did you switch the measures in columns to rows in a Matrix visual? If so, please refer to the settings below.

     

  • I whish it was that simple, But because I'm using Caculated Item there is no such option

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi AlissaStuart ,

    Thank you for reaching out to Microsoft fabric community forum.

     

    Since your rows are generated from a calculation group, the Matrix can't directly apply color to the row headers. However, you can still achieve clear row banding by coloring the values according to the calculation item in each row. To do this, create a simple color measure that checks the selected calc item (using SELECTEDVALUE('Calc Group'[Name])) and returns a hex color with a SWITCH statement, assigning each item or subgroup a specific color. To handle totals, use IF(NOT ISINSCOPE('Calc Group'[Name]), BLANK(), <color>). Then, in the Matrix, use Conditional formatting - Background color - Field value and select this color measure for the Values/Totals. This will shade each data row by calc item, giving you the subgroup highlights you want without changing your calc group setup. If you have many items, consider adding a [Subgroup] column to the calc group table and use it in your SWITCH to keep color assignments organized.

    Create calculation groups in Power BI - Power BI | Microsoft Learn

     

    Hope this helps. Please reach out for further assistance.

    Thank you.

    • legenda689's avatar
      legenda689
      Regular Visitor

      Thatnk you for your answer, but I'm still a bit confused about the script. 

      First, here is what my Calculation Group looks like. 

       


      so  if I understood correctly my script will begin with something like this (I wrote it only for one vale so far)? 

      Conditional Format =
      SWITCH(
          SELECTEDVALUE('Calculation group'[Calculation group column]),
          [Job Starts],"#72c197","#72c177"
      )
      But when I apply to the table via following method nothing happens to the table. 

       

      I think my mistake is using [ ] to select job start. 

      Can you please help again? 
      Thank you, 
      Alissa 

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi AlissaStuart ,

       

      I wanted to check if you had the opportunity to review the information provided. If you still require support, please let us know, we are happy to assist you.

       

      Thank you.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi legenda689 ,

     

    The behavior you're experiencing is normal, as calculation items cannot be referenced using [MeasureName]. Instead, in a calculation group, you should compare against the calculation item name text. Please modify your color measure so that the SWITCH function checks the item names as listed in your Calculation Items.

    Conditional Format =
    SWITCH(
        SELECTEDVALUE( 'Calculation group'[Calculation group column] ),
        "Job Starts", "#72c197",
        "Job Starts YouthHSN", "#FFFF66",
        BLANK()
    )
    

    Once you've updated the measure, navigate to Conditional Formatting > Background color > Field Value and choose this measure. This will return the correct color hex based on the selected calculation item, allowing the matrix to apply row shading as intended.

    This method will ensure that row-level coloring functions properly for calculation groups.

     

    Thank you.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi legenda689 ,

     

    We haven’t received an update from you in some time. Could you please let us know if the issue has been resolved?
    If you still require support, please let us know, we are happy to assist you.

     

    Thank you.