Forum Discussion

mhablas426's avatar
mhablas426
Icon for Advocate II rankAdvocate II
2 years ago
Solved

Conditionals formatting based on a column in the same visualization table

Guys,
I want to make conditional formatting based on column number (3) for the below table using DAX:
the values of column num (2) will appear in red if they exceed the values in front of it in column num (3), and they will be displayed in green if they do not exceed.
And please How can I apply this Dax to the table?
Thanks a lot
Table

12 Replies

  • mhablas426 , You can create a simple DAX for this

     

    Column2Color =
    IF(
    SELECTEDVALUE('YourTable'[Column2]) > SELECTEDVALUE('YourTable'[Column3]),
    "Red",
    "Green"
    )

     

    Select the Table Visual: Click on the table visual where you want to apply the conditional formatting.

    Open Conditional Formatting Options:

    Go to the Format pane.
    Expand the Conditional formatting section.
    Click on the fx button next to the Font color option for the column you want to format (Column 2 in this case).
    Set Up Conditional Formatting:

    In the Conditional formatting window, select Field value under the Format by dropdown.
    In the Based on field dropdown, select the measure you created (Column2Color).
    Apply the Formatting: Click OK to apply the conditional formatting.

  • It's a visualization table, not an data or regular table and I used the below measure to build it

    Fuel Current Month Q =
    CALCULATE(
        SUM('BI Fuel Issue'[Fuel Day Quantity])+SUM('BI Fuel Issue'[Fuel Night Quantity]),
        MONTH('F Dim Date'[Date])=MONTH(TODAY()),
        YEAR('F Dim Date'[Date])=YEAR(TODAY())
    )
     so the question now How can I do the above measure as a table so can apply your answer to it

     

    • bhanu_gautam's avatar
      bhanu_gautam
      Icon for Super User rankSuper User

      mhablas426 , First create a measure as per columns in your table

      ColorMeasure =
      IF(
      [Fuel Current Month Q] > [SomeOtherMeasure], -- Replace [SomeOtherMeasure] with the actual measure or column you want to compare against
      "Red",
      "Green"
      )

       

      Then

      1.Go to the Report view.
      2.Add a table visual to the report and include the columns you want to display.
      3.Select the table visual.
      4.Go to the Format pane (paint roller icon).
      5.Expand the Conditional formatting section.
      6.Click on the drop-down arrow next to the column you want to format (e.g., Fuel Current Month Q) and select Background color or Font color.
      7.In the Conditional formatting window:
      Set the Format by option to Field value.
      8.Set the Based on field option to the measure you created (ColorMeasure).
      Click OK to apply the conditional formatting.

      • mhablas426's avatar
        mhablas426
        Icon for Advocate II rankAdvocate II

        Thanks for your reply and your time, but I want first to convert this visualization table to a data table, a regular table!! How can I do that?
        thank you again