Forum Discussion
conditional formatting by field not available for direct query
- 7 years ago
Hey,
I can't confirm this, make sure you are using the latest Power BI Desktop version, I'm using the May 2019 release (check --> Help --> About).
Here you can see that I'm connected to a data model using direct query:
This directquery data source is a SQL Server 2017 database, but I can also confirm that this also works with other dirctquery datasources.
Make sure that your measure returns a text string, this string has to be either
- a valid color name (https://www.w3schools.com/colors/colors_names.asp) or
- a valid hexcode representing one of the unnamed colors (including the # sign
This is how I apply a measure for conditional formatting (here the background):
I choose: Format by "Field value":
I select the measure that returns the text encoded color that I want to apply to the background:
And this is how the table will look like:
And this is how the measure look liks:
vizAid Background Color - Quantity = SWITCH( TRUE() , v_Quantity < 11000, [vizAid trafficlight bad] , AND([Total Quantity] >= 11000, [Total Quantity] < 15000) , [vizAid Color trafficlight maybe] , "Darkgrey" )This measure is referencing two other measures, these measures just define a color, like so:
vizAid trafficlight bad = "Crimson"
Hopefully this provides some ideas.
Regards,
Tom
Hey,
I can't confirm this, make sure you are using the latest Power BI Desktop version, I'm using the May 2019 release (check --> Help --> About).
Here you can see that I'm connected to a data model using direct query:
This directquery data source is a SQL Server 2017 database, but I can also confirm that this also works with other dirctquery datasources.
Make sure that your measure returns a text string, this string has to be either
- a valid color name (https://www.w3schools.com/colors/colors_names.asp) or
- a valid hexcode representing one of the unnamed colors (including the # sign
This is how I apply a measure for conditional formatting (here the background):
I choose: Format by "Field value":
I select the measure that returns the text encoded color that I want to apply to the background:
And this is how the table will look like:
And this is how the measure look liks:
vizAid Background Color - Quantity =
SWITCH(
TRUE()
, v_Quantity < 11000, [vizAid trafficlight bad]
, AND([Total Quantity] >= 11000, [Total Quantity] < 15000) , [vizAid Color trafficlight maybe]
, "Darkgrey"
)
This measure is referencing two other measures, these measures just define a color, like so:
vizAid trafficlight bad = "Crimson"
Hopefully this provides some ideas.
Regards,
Tom
Hi TomMartens ,
I've also arrived with this solution, but the problem is that I can only make it work without RLS when I apply RLS everything crashes.
Sorry the message is half Spanish half English.
Any ideas why?