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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
MakingBreaddata
Regular Visitor

Conditional formating based on a relation to other datasources

Hey there,

 

i want to highline the data in my matrix which is out of the specification:

MakingBreaddata_0-1692090513057.png

for example the weight for the article 8956 (formating of the column is text) should be between 125 - 128. In my case it is 124 so it has to be marked with a red backround. I tried the standard conditional formating but it did not work, it is easy to made in excel so it should also work in Power bi. Anyone an idea?

 

regards

 

 

1 ACCEPTED SOLUTION

Hey @MakingBreaddata ,

 

the matrix visual shows values for different numeric columns or measures like "Summe von Weight". Without knowing the exact "source" of the values it's difficult to provide 100% exact guidance. 

 

However,  if the numeric expression is "coming" from a column (my assumption) then you can replace the line

var currentValue = [a measure returning the value you want to check]

with this line

var currentValue = SUM( 'FactOnlineSales'[SalesAmount] )

Please keep in mind that creating explicit measures instead of using implicit measures is considered a best practice (one of the many readings: https://towardsdatascience.com/understanding-explicit-vs-implicit-measures-in-power-bi-e35b578808ca).

 

After you created the measure that returns the "colorname" or a color hexcode as a string "#eb7134" you have to select the measure for the color coding. Make sure that the data tpye of the measure is "text." If this is not the case it can not be selected in a later step:
image.png

 

Here are the steps to select the measure for the color coding:

  • Mark the table or matrix visual
  • Enable the conditional formatting in the formatting pane, for matrix visuals you will find this on the Cell elements  card
    TomMartens_0-1692162783624.png
  • Choose the "Field value" format style and select the measure
    TomMartens_1-1692162965445.png

     

Hopefully this provides what you are looking for.

 

Regards,

Tom

 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

5 REPLIES 5
TomMartens
Super User
Super User

Hey @MakingBreaddata ,

 

I'm wondering why it's not possible to use Rules for the conditional formatting like so:

image.png

The result:

TomMartens_0-1692094280861.png

Here you will find the article that explains the conditional formatting: https://learn.microsoft.com/en-us/power-bi/create-reports/desktop-conditional-table-formatting

 

Hopefully, this provides what you are looking for.

 

Regards,

Tom

 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Hey @TomMartens , 

but how can i set up a specific Rule for each article. In your example you set up a range between 200 - 250 $ for every article. But i want to set up a different range for every article. In your table this would mean that the range for 23012961 is between 200 - 250 $ (it gets an yellow backround) and for 23012962 the range should be between 180 - 200 $ (the backround is still blank, it would dye when the value is between 180 - 200 $).

 

or formulated as a rule: if the line in the coulumn OnlineSalesKey is 23012961, all values between 200 - 250  should be marked; if the line in the coulumn OnlineSalesKey is 23012961 all values betwenn 180 - 200 should be marked; and so on for every article.

 

Hope this is understandable. Thank you in advance.

 

Hey @MakingBreaddata ,

 

you must provide a table containing the min and max value per article, I assume this table is called rangeTable and has the columns: Article | lowerbound | upperbound.

 

Then you can create a measure  that returns the backglround color like so:

 

 

vizAid bgc Value = 
var currentArticle = SELECTEDVALUE( '<dimTable>'[Article] )
var currentValue = [a measure returning the value you want to check]
var lowerbound = CALCULATE( MIN( 'rangeTable'[lowerbound] ) , '<dimTable>'[Article] = currentArticle )
var upperbound = CALCULATE( MAX( 'rangeTable'[upperbound] ) , '<dimTable>'[Article] = currentArticle )
return
IF( currentValue >= lowerbound && currentValue <= upperbound
    , "red"
    , BLANK()
)

 

Make sure the measure is of data type string.

Choose the conditional formatting option Field value and select the measure.

Hopefully, this provides what you are looking for.

Regards,

Tom

 

 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

(English below)

Hallo Tom,

was ist mit 

var currentValue = [a measure returning the value you want to check]

gemeint, könntest du das an einem Beispiel festmachen? Und wo gebe ich das Measure ein ("Choose the conditional formatting option Field value and select the measure.") Vielen Dank im Voraus.

 

English:

 

Hello Tom,

 

what do you mean with 

var currentValue = [a measure returning the value you want to check]

could you give me an example for that? Where should i have to put in the measure ("Choose the conditional formatting option Field value and select the measure."? Thank you in advance!

Hey @MakingBreaddata ,

 

the matrix visual shows values for different numeric columns or measures like "Summe von Weight". Without knowing the exact "source" of the values it's difficult to provide 100% exact guidance. 

 

However,  if the numeric expression is "coming" from a column (my assumption) then you can replace the line

var currentValue = [a measure returning the value you want to check]

with this line

var currentValue = SUM( 'FactOnlineSales'[SalesAmount] )

Please keep in mind that creating explicit measures instead of using implicit measures is considered a best practice (one of the many readings: https://towardsdatascience.com/understanding-explicit-vs-implicit-measures-in-power-bi-e35b578808ca).

 

After you created the measure that returns the "colorname" or a color hexcode as a string "#eb7134" you have to select the measure for the color coding. Make sure that the data tpye of the measure is "text." If this is not the case it can not be selected in a later step:
image.png

 

Here are the steps to select the measure for the color coding:

  • Mark the table or matrix visual
  • Enable the conditional formatting in the formatting pane, for matrix visuals you will find this on the Cell elements  card
    TomMartens_0-1692162783624.png
  • Choose the "Field value" format style and select the measure
    TomMartens_1-1692162965445.png

     

Hopefully this provides what you are looking for.

 

Regards,

Tom

 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.