Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Cheng2202
Regular Visitor

Conditional format on matrix table

I want to make an icon conditional format on a matrix table but I have som issues. I can just make conditional format based on one column but I want it to compare with another one. I also just want the icons just on "Totalt" and not the sum of "Budsjett". I want the icons to come as follows:

 

Red: When "Totalt" is 0. Yellow: When "Totalt" is between 0-10% of "Budsjett". Green: When "Totalt" is over 10% of "Budsjett" Is this possible? How?

 

Picture 1: The matrix table.

conditional-format-on-matrix-table-v0-7ck1lgrhputc1.jpeg

Picture 2: How it is set up.

conditional-format-on-matrix-table-v0-2ftg936jputc1.jpeg

Picture 3: The measure on value ("Verdier").

conditional-format-on-matrix-table-v0-txs0yf1kputc1.jpeg


 

 

 

8 REPLIES 8
v-jianpeng-msft
Community Support
Community Support

Your solution is great, @johnbasha33 . It worked like a charm!

Hi, @Cheng2202 

Have you already solved the current problem? I tried the workaround of johnbasha33 using the following sample data and it worked

vjianpengmsft_0-1713768394029.png

I have the following table visual, and then I create one measure using the following DAX expression:

vjianpengmsft_1-1713768551495.png

icon color = 
SWITCH(TRUE(),
[Profit]*0.1>=[Input],"green",
[Profit]>0&&[Profit]*0.1<[Input],"yellow",
"red")

vjianpengmsft_2-1713768646503.png

Set the conditional formatting as follows:

vjianpengmsft_3-1713768729883.png

Here are the results:

vjianpengmsft_4-1713768757134.png

 

How to Get Your Question Answered Quickly

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

Best Regards

Jianpeng Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

@johnbasha33 @v-jianpeng-msft 

Thanks for your help and sorry for late reply! Had much to do lately.

 

I encountered a problem with the measure. On "SELECTEDVALUE('YourTable'[Totalt])" and "SELECTEDVALUE('YourTable'[Budsjett])" I can't fill in as those numbers are from another measure and not in the table. The measure for..

 

..Totalt is:

Cheng2202_0-1714385201819.jpeg

 

..Budsjett is:

Cheng2202_1-1714390400353.png

 

Do you have any solution for this? 😊

Hi, @Cheng2202 

Thank you very much for your reply. If you're two measures, then your DAX expression looks like this:

icon color = 
SWITCH(TRUE(),
[Totalt]>[Budsjett]*0.1,"green",
[Totalt]>0&&[Totalt]<=[Budsjett]*0.1,"yellow",
"red")

Then you need to put these three measures in the matrix table and conditionally format the icon color.

 

 

How to Get Your Question Answered Quickly

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

Best Regards

Jianpeng Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-jianpeng-msft And I also wondered how can I make it work on a matrix table and not a normal table as in your example:

Cheng2202_3-1714470987470.png

 

In a normal table I can't get the right lines after first column and fat text in the last column:

Cheng2202_1-1714470796860.pngCheng2202_2-1714470893457.png

Are there any solution for that? 🤔

@v-jianpeng-msft Is it possible to remove where it says yellow? 🤔

 

Cheng2202_6-1714470118344.png

 

 

Hi @Cheng2202 

Thank you for your reply, you can remove the yellow from the totals row. You need to use the ISINSCOPE or HASONEVALUE function to determine whether the current row is a total row.

HASONEVALUE function (DAX) - DAX | Microsoft Learn

ISINSCOPE function (DAX) - DAX | Microsoft Learn

Here's a reference for using them to remove totals:

vjianpengmsft_0-1714719431443.png

Just change the DAX expression in the image to:

icon color = IF(
    ISINSCOPE('Table'[Product]),
    SWITCH(TRUE(),
        [sales amount]>=300,"green",
        [sales amount]>=200,"yellow",
        "red"
    )
)

Here's what it looks like:

vjianpengmsft_1-1714719532993.png

 

 

 

How to Get Your Question Answered Quickly

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

Best Regards

Jianpeng Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

johnbasha33
Solution Sage
Solution Sage

@Cheng2202 

To achieve conditional formatting based on multiple conditions and comparison between two columns in a matrix table in Power BI, you can follow these steps:

1. **Create Conditional Formatting Measure**:
Create a measure that calculates the color based on your conditions. You can use DAX expressions to evaluate the conditions and return the appropriate color code. Here's an example measure:

```DAX
Conditional Format =
VAR Totalt = SELECTEDVALUE('YourTable'[Totalt])
VAR Budsjett = SELECTEDVALUE('YourTable'[Budsjett])
VAR PercentOfBudsjett = Totalt / Budsjett
RETURN
SWITCH(
TRUE(),
Totalt = 0, "Red",
AND(PercentOfBudsjett > 0, PercentOfBudsjett <= 0.1), "Yellow",
PercentOfBudsjett > 0.1, "Green",
BLANK()
)
```

Replace `'YourTable'`, `'Totalt'`, and `'Budsjett'` with your actual table name and column names.

2. **Apply Conditional Formatting**:
Go to the conditional formatting settings for the "Totalt" column in your matrix table. Choose "Icon Sets" as the formatting type. Then, use the measure you created above as the field to base the icons on.

3. **Configure Icon Rules**:
Set up three icon rules corresponding to your conditions:
- Red: Rule where the measure equals "Red".
- Yellow: Rule where the measure equals "Yellow".
- Green: Rule where the measure equals "Green".

4. **Ensure Icons Only on "Totalt"**:
Make sure the conditional formatting is applied only to the "Totalt" values and not the "Budsjett" values. You can adjust the conditional formatting settings to target only the "Totalt" column.

By following these steps, you should be able to apply conditional formatting with icons based on multiple conditions and comparison between two columns in your matrix table in Power BI. Adjust the measure and rules as needed to fit your specific requirements.


Did I answer your question? Mark my post as a solution! Appreciate your Kudos !!

@johnbasha33 Replied to wrong message 😅

Thanks for your help and sorry for late reply! Had much to do lately.

 

I encountered a problem with the measure. On "SELECTEDVALUE('YourTable'[Totalt])" and "SELECTEDVALUE('YourTable'[Budsjett])" I can't fill in as those numbers are from another measure and not in the table. The measure for..

 

..Totalt is:

Cheng2202_12-1714470321786.jpeg

..Budsjett is:

Cheng2202_13-1714470331972.png

 

 

Do you have any solution for this? 😊

 

 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.