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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
majid154a
Frequent Visitor

Define colors for 3 KPI for each zones

helpDear Experts,

I have been struggling for a long time to solve my problem, and I haven't found a solution yet.

Problem Description:

I have delivery company data that includes zones and the following key indicators:

  • Average order time
  • Average vendor acceptance time
  • Average delivery time to the customer

Challenge:

I want to color the three indicators in green and red based on achieving the target or not, noting that the target for each zone is different.

Target details by zones:

  • In Zone A:

    • Average order time: <= 35 minutes (Green), less than that (Red)
    • Average vendor acceptance time: <= 3 minutes (Green), less than that (Red)
    • Average delivery time to the customer: <= 15 minutes (Green), less than that (Red)
  • In Zone B:

    • Average order time: <= 30 minutes (Green), less than that (Red)
    • Average vendor acceptance time: <= 4 minutes (Green), less than that (Red)
    • Average delivery time to the customer: <=20 minutes (Green), less than that (Red)
  • In Zone C:

    • Average order time: <= 40 minutes (Green), less than that (Red)
    • Average vendor acceptance time: <=5 minutes (Green), less than that (Red)
    • Average delivery time to the customer: <= 25 minutes (Green), less than that (Red)

      I need to display a matrix chart with zones in the rows and the three KPIs in the values.

I kindly request your assistance in solving this problem and dynamically applying the coloring based on the specified conditions for each zone.

Thank you in advance for your cooperation.


Attached Data as example:

Zones total order timevendor Acceptance time arrival at customer time
A37424
B38527
B22528
C27223
A26210
A40114
C28412
C31327
A17125
B39210
B22429
C33319
A23717
A16225
C32715
C39125
A33416
A22112
C36329
C32718
A29329
B38216
B36529
C31111
A40726
2 ACCEPTED SOLUTIONS
Irwan
Super User
Super User

hello @majid154a 

 

please check if this accomodate your need.

Irwan_0-1720827168617.png

 

1. Create a measure for 'total order time' conditional formating.

Order Color Palette =
var _Zone = SELECTEDVALUE('Table'[Zones])
var _OrderTime = SELECTEDVALUE('Table'[ total order time])
Return
IF(
    _Zone="A"&&_OrderTime<=35, //Zone A and Order Time less than or equal 35
    "#00FF00", //Green Code
IF(
    _Zone="B"&&_OrderTime<=30, //Zone B and Order Time less than or equal 30
    "#00FF00", //Green Code
IF(
    _Zone="C"&&_OrderTime<=40, //Zone C and Order Time less than or equal 40
    "#00FF00", //Green Code
    "#FF0000" //Red Code
)))
Irwan_3-1720827524159.png

 

2. Create a measure for 'vendor acceptance time' conditional formating.

Vendor Color Palette =
var _Zone = SELECTEDVALUE('Table'[Zones])
var _VendorTime = SELECTEDVALUE('Table'[vendor Acceptance time])
Return
IF(
    _Zone="A"&&_VendorTime<=3, //Zone A and Vendor Time less than or equal 3
    "#00FF00", //Green Code
IF(
    _Zone="B"&&_VendorTime<=4, //Zone B and Vendor Time less than or equal 34
    "#00FF00", //Green Code
IF(
    _Zone="C"&&_VendorTime<=5, //Zone C and Vendor Time less than or equal 5
    "#00FF00", //Green Code
    "#FF0000" //Red Code
)))
Irwan_2-1720827459942.png

 

3. Create a measure for 'arrival at customer time' conditional formating.

Customer Color Palette =
var _Zone = SELECTEDVALUE('Table'[Zones])
var _CustomerTime = SELECTEDVALUE('Table'[ arrival at customer time])
Return
IF(
    _Zone="A"&&_CustomerTime<=15, //Zone A and Customer Time less than or equal 15
    "#00FF00", //Green Code
IF(
    _Zone="B"&&_CustomerTime<=20, //Zone B and Customer Time less than or equal 20
    "#00FF00", //Green Code
IF(
    _Zone="C"&&_CustomerTime<=25, //Zone C and Customer Time less than or equal 25
    "#00FF00", //Green Code
    "#FF0000" //Red Code
)))
Irwan_4-1720827642501.png

 

4. Plot your data, hit that arrow in 'total order time' Columns value, select Conditional Formatting, then pick conditional formatting you want (background or font color). I picked background color in this case.

Irwan_5-1720827777524.png

 

5. Hit Format Style and choose Field Value

Irwan_6-1720827964693.png

 

6. Choose your table, then select the 'Order Colot Palette" measure that previously made for 'total order time'. then OK.

Irwan_7-1720828042165.png

 

7. Do exact same way for 'vendor acceptance time' and 'arrival at customer time'.

Irwan_8-1720828145407.png

 

You have to make sure to select vendor color measure for 'vendor acceptance time' and customer color measure for 'arrival at customer time'.

 

Hope this will help you.

Thank you.

View solution in original post

hello @majid154a 

 

glad to be a help.

select icon if you want to have icon conditional formating.

1. Change the color code into number. This is for measure average total order, do exact same way for measure average vendor acceptance time and measure average arrival at customer time.

Order Color Palette =
var _Zone = SELECTEDVALUE('Table'[Zones])
var _OrderTime = SELECTEDVALUE('Table'[ total order time])
Return
IF(
    _Zone="A"&&AVERAGE('Table'[ total order time])<=35, //Zone A and Order Time less than or equal 35
    1,
IF(
    _Zone="B"&&AVERAGE('Table'[ total order time])<=30, //Zone B and Order Time less than or equal 30
    2,
IF(
    _Zone="C"&&AVERAGE('Table'[ total order time])<=40, //Zone C and Order Time less than or equal 40
    3,
    4
)))
 
2. Choose Icon in conditional formatting.

Irwan_0-1720993633052.png

 

3. Choose Rules in Format Style, then select the measure you are working on (I used average total order for this example).

Irwan_1-1720994871716.png

Icon layout is for icon position.

- Make sure to change "If Value" into equal then put your measure number. For example: in measure average total order time, I used 1 if Zone A and Average Total Order Time less than 35.

- Make sure to change into Number (dont use Percent).

- Select your preferences icons.

Irwan_2-1720995142763.png

 

Do this for vendor acceptance time and arrival at customer time.

 

Hope this will help you.

Thank you.

View solution in original post

9 REPLIES 9
Irwan
Super User
Super User

hello @majid154a 

 

please check if this accomodate your need.

Irwan_0-1720827168617.png

 

1. Create a measure for 'total order time' conditional formating.

Order Color Palette =
var _Zone = SELECTEDVALUE('Table'[Zones])
var _OrderTime = SELECTEDVALUE('Table'[ total order time])
Return
IF(
    _Zone="A"&&_OrderTime<=35, //Zone A and Order Time less than or equal 35
    "#00FF00", //Green Code
IF(
    _Zone="B"&&_OrderTime<=30, //Zone B and Order Time less than or equal 30
    "#00FF00", //Green Code
IF(
    _Zone="C"&&_OrderTime<=40, //Zone C and Order Time less than or equal 40
    "#00FF00", //Green Code
    "#FF0000" //Red Code
)))
Irwan_3-1720827524159.png

 

2. Create a measure for 'vendor acceptance time' conditional formating.

Vendor Color Palette =
var _Zone = SELECTEDVALUE('Table'[Zones])
var _VendorTime = SELECTEDVALUE('Table'[vendor Acceptance time])
Return
IF(
    _Zone="A"&&_VendorTime<=3, //Zone A and Vendor Time less than or equal 3
    "#00FF00", //Green Code
IF(
    _Zone="B"&&_VendorTime<=4, //Zone B and Vendor Time less than or equal 34
    "#00FF00", //Green Code
IF(
    _Zone="C"&&_VendorTime<=5, //Zone C and Vendor Time less than or equal 5
    "#00FF00", //Green Code
    "#FF0000" //Red Code
)))
Irwan_2-1720827459942.png

 

3. Create a measure for 'arrival at customer time' conditional formating.

Customer Color Palette =
var _Zone = SELECTEDVALUE('Table'[Zones])
var _CustomerTime = SELECTEDVALUE('Table'[ arrival at customer time])
Return
IF(
    _Zone="A"&&_CustomerTime<=15, //Zone A and Customer Time less than or equal 15
    "#00FF00", //Green Code
IF(
    _Zone="B"&&_CustomerTime<=20, //Zone B and Customer Time less than or equal 20
    "#00FF00", //Green Code
IF(
    _Zone="C"&&_CustomerTime<=25, //Zone C and Customer Time less than or equal 25
    "#00FF00", //Green Code
    "#FF0000" //Red Code
)))
Irwan_4-1720827642501.png

 

4. Plot your data, hit that arrow in 'total order time' Columns value, select Conditional Formatting, then pick conditional formatting you want (background or font color). I picked background color in this case.

Irwan_5-1720827777524.png

 

5. Hit Format Style and choose Field Value

Irwan_6-1720827964693.png

 

6. Choose your table, then select the 'Order Colot Palette" measure that previously made for 'total order time'. then OK.

Irwan_7-1720828042165.png

 

7. Do exact same way for 'vendor acceptance time' and 'arrival at customer time'.

Irwan_8-1720828145407.png

 

You have to make sure to select vendor color measure for 'vendor acceptance time' and customer color measure for 'arrival at customer time'.

 

Hope this will help you.

Thank you.

Hi @Irwan 

 

I tested this code, and it showed me color codes instead of numbers.
I have attached the code used for your reference.

 

majid154a_0-1720865727255.png

 

 

majid154a_1-1720865764365.png

 

Hello @majid154a 

 

following my post replying your question above, you place your column into matrix column value not those measures you made.

 

These measures are used to assign color based on average value of your column ('total order time', 'vendor acceptance time', and 'arrival at customer time'). So do not place those measure for your matrix column value.

Irwan_10-1720909292924.png

 

 

1. you place your column value in matrix visual as below image (use average value).

Irwan_1-1720915153802.png

 

2. hit that down arrow to assign color based on measures you made before.

Irwan_2-1720915678759.png

 

3. select Field Value in Format Style and choose the measure based on the column you are working on.

for example, I tried to assign color to 'total order time' and so i choose measure 'Order Color Palette' because 'Order Color Palette' has conditional if color for 'total order time'

Irwan_9-1720909136888.png

 

4. and do exact same way for 'vendor acceptance time' and 'arrival at customer time'.

 

Hope this will help you.

Thank you.

Thank you @Irwan  very much for your kind help.

You used SELECTEDVALUE in the three measures because it is applied to a column. How can I then convert it to the average for each of the three measures, as the requirement is for the average, as I mentioned in the question?

 

Also, zones should appear only once for each zone (don't summarize). The numbers will change based on the slicers available.

 

Also, can I use icons instead of backgrounds?
 

I greatly appreciate your assistance and am grateful for your cooperation.

Is it possible to send the file in which you solved the example?

Thank you again.

Hello @majid154a ,

 

those measures are used for defining color based on conditional if.

 

Yes, you can choose many option for conditional formating.

Irwan_1-1720907830601.png

 

Ah sorry, I misunderstood your goal.

Here is the update. I have changed into matrix visual so zones are appear only once.

Irwan_0-1720913657011.png

 

Here is the DAX for measure to assign average value : 

Customer Color Palette =
var _Zone = SELECTEDVALUE('Table'[Zones])
var _CustomerTime = SELECTEDVALUE('Table'[ arrival at customer time])
Return
IF(
    _Zone="A"&&AVERAGE('Table'[ arrival at customer time])<=15, //Zone A and Customer Time less than or equal 15
    "#00FF00", //Green Code
IF(
    _Zone="B"&&AVERAGE('Table'[ arrival at customer time])<=20, //Zone B and Customer Time less than or equal 20
    "#00FF00", //Green Code
IF(
    _Zone="C"&&AVERAGE('Table'[ arrival at customer time])<=25, //Zone C and Customer Time less than or equal 25
    "#00FF00", //Green Code
    "#FF0000" //Red Code
)))
 
Order Color Palette =
var _Zone = SELECTEDVALUE('Table'[Zones])
var _OrderTime = SELECTEDVALUE('Table'[ total order time])
Return
IF(
    _Zone="A"&&AVERAGE('Table'[ total order time])<=35, //Zone A and Order Time less than or equal 35
    "#00FF00", //Green Code
IF(
    _Zone="B"&&AVERAGE('Table'[ total order time])<=30, //Zone B and Order Time less than or equal 30
    "#00FF00", //Green Code
IF(
    _Zone="C"&&AVERAGE('Table'[ total order time])<=40, //Zone C and Order Time less than or equal 40
    "#00FF00", //Green Code
    "#FF0000" //Red Code
)))
 
Vendor Color Palette =
var _Zone = SELECTEDVALUE('Table'[Zones])
var _VendorTime = SELECTEDVALUE('Table'[vendor Acceptance time])
Return
IF(
    _Zone="A"&&AVERAGE('Table'[vendor Acceptance time])<=3, //Zone A and Vendor Time less than or equal 3
    "#00FF00", //Green Code
IF(
    _Zone="B"&&AVERAGE('Table'[vendor Acceptance time])<=4, //Zone B and Vendor Time less than or equal 34
    "#00FF00", //Green Code
IF(
    _Zone="C"&&AVERAGE('Table'[vendor Acceptance time])<=5, //Zone C and Vendor Time less than or equal 5
    "#00FF00", //Green Code
    "#FF0000" //Red Code
)))

 

Change column value into average (default is sum). and do this for all your column value ('total order time', 'vendor acceptance time', and 'arrival at customer time')

Irwan_5-1720908634384.png

 

Please check this link for pbix download.

https://www.dropbox.com/scl/fi/poc630a39nuer73mprhqb/4039971-M160184.pbix?rlkey=zrg18mejsc0evpoddck2... 

 

Hope this will help you.

Thank you.

Thank you @Irwan ,

dear brother. I have tried the solution, and it worked correctly for me. I just need to know how to make the indicators appear as icons, as shown in the attachment, instead of the background.

Tnank you again in advanced @Irwan 

hello @majid154a 

 

glad to be a help.

select icon if you want to have icon conditional formating.

1. Change the color code into number. This is for measure average total order, do exact same way for measure average vendor acceptance time and measure average arrival at customer time.

Order Color Palette =
var _Zone = SELECTEDVALUE('Table'[Zones])
var _OrderTime = SELECTEDVALUE('Table'[ total order time])
Return
IF(
    _Zone="A"&&AVERAGE('Table'[ total order time])<=35, //Zone A and Order Time less than or equal 35
    1,
IF(
    _Zone="B"&&AVERAGE('Table'[ total order time])<=30, //Zone B and Order Time less than or equal 30
    2,
IF(
    _Zone="C"&&AVERAGE('Table'[ total order time])<=40, //Zone C and Order Time less than or equal 40
    3,
    4
)))
 
2. Choose Icon in conditional formatting.

Irwan_0-1720993633052.png

 

3. Choose Rules in Format Style, then select the measure you are working on (I used average total order for this example).

Irwan_1-1720994871716.png

Icon layout is for icon position.

- Make sure to change "If Value" into equal then put your measure number. For example: in measure average total order time, I used 1 if Zone A and Average Total Order Time less than 35.

- Make sure to change into Number (dont use Percent).

- Select your preferences icons.

Irwan_2-1720995142763.png

 

Do this for vendor acceptance time and arrival at customer time.

 

Hope this will help you.

Thank you.

Thank you @Irwan , my dear brother, for helping me with the solution. I applied your solution, and it works correctly.

Thank you a hundred times

hello @majid154a 

 

glad to be a help.


Thank you.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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