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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
amikm
Helper V
Helper V

Issue with conditional formatting for a table visual having measures in it

I am using the below table for reporting where the Product is coming from a product table and Q1Sales, Q2Sales,Q3Sales,Q4Sales are measures calculated using date and Sales Data

amikm_0-1660148422564.png

 

I need to do conditional formatting for each Product (each row)
Suppose for-
Apple if 1000-5000-> Red, 5001-8000-> Yellow, 8001+ -> Green
Samsung if 1000-5000-> Red, 5001-10000-> Yellow, 10000+ -> Green
OnePlus if 1000-4000-> Red, 4001-8000> Yellow, 8000+ -> Green
MI  if 1000-8000-> Red, 8001-10000-> Yellow, 8000+ -> Green

 

When I am trying to do this, I am not able to use multiple conditional formatting for the same measures. 

Can we use some DAX for this?

 

9 REPLIES 9
srlabhe123
Post Patron
Post Patron

create varflag as measure and use sum(varflag) for conditional formatting

Hi @srlabhe123, Whenever I am trying to write the above Dax as a measure, It is giving me an error.
And If we try to create multiple calculated columns for each product and apply them to each measure then it is also causing a circular dependency error.

This means, I have created a column for Samsung and applied that column for conditional formatting for Q1Sales
and when I am trying to create a column for Apply and applying that for conditional formatting of Q2Sales it is giving a circular dependency error

Could you please share the pbix with measure and columns that can work for all measures (Q,Q2,Q3 and Q4)

Aldo, whatever column I am creating inside the model and trying to use in Power Bi for conditional formatting is not working means no color formatting is applying. The calculated column is grayed out 

@srlabhe123 , could you tell me what is wrong if my source is Azure analysis service as whatever column I am creating is getting grayed out?
Also If you try to create calculate column, It will give you dependency error If you will start writing logic for Q2Sales

srlabhe123
Post Patron
Post Patron

Create VarFlag as measure and use sum(varflag) to setup formatting 

jamilqpr
Frequent Visitor

First, decide and choose which variable will affect value color or background cell color, In this case you will choose sum of sale, and put your condition accordingly, 

In my screen, I used as % value of total sales with the same format. I just want to show data bars in different colors accordingly by employee sales. This is how I formatted data barsThis is how I formatted data barsIf i select nothing the data barsIf i select nothing the data bars

If I select year 2015 from slicer then data bars colorIf I select year 2015 from slicer then data bars color

 

Still have any question, I think you got it

AlanP514
Helper V
Helper V

Hi @amikm 
Please create one calculated column using this Dax 
Background Colour. =
iF(
    Product[Product] = Apple  > 1000-5000 ,"Red" ,
IF(
    Product[Product] = Apple >  5001-8000 , "Yellow",
 IF(
    Product[Product] = Apple > 8001+ ,"Green")
))


You can create the entire measure this way , put conditional formatting using field value

@AlanP514  @srlabhe123 
I have done that but the column is grayed out when I am using it while doing conditional formatting.
My data source is azure analysis services. Is it the reason for grayed out?

srlabhe123
Post Patron
Post Patron

Hi 

Say for measure Q1 Sales

Create flag say VarFlag= if(Product ="Apple" && Q1Sales>= 1000 && Q1Sales<= 5000, 0,

if(Product ="Apple" && Q1Sales>= 5001 && Q1Sales<= 8000, 1,-1))

Then use Colorcoding like below, it shoudl work 

srlabhe123_0-1660155967787.png

 

thanks, @srlabhe123,
Looks like varflag is a calculated column. But in my case varflag is grayed out when I am trying to use this column for conditional formatting, any reason for this? or it is grayed out because of I have created this column in cube ( tabular model)

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.