cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Capstone
Resolver I
Resolver I

conditional formatting by field not available for direct query

I have a direct query model and I want to conditional format a field (Worksite) based on hex values for that site. I have created a measure which gives the hex values for each site. But when I go to conditional formatting and select format by field value I cannot select the measure ( I cannot select any measure in the model). Is this a known issue ? I know I can do so in import mode and it worked successfully. Manually applying colours is not an option as there are too many charts which needs updating. Any ideas ?

1 ACCEPTED SOLUTION
TomMartens
Super User II
Super User II

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:

image.png

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

This is how I apply a measure for conditional formatting (here the background):

image.png

 

I choose: Format by "Field value":

image.png

I select the measure that returns the text encoded color that I want to apply to the background:

image.png

And this is how the table will look like:

image.png

 

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

 

 

 



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 II
Super User II

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:

image.png

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

This is how I apply a measure for conditional formatting (here the background):

image.png

 

I choose: Format by "Field value":

image.png

I select the measure that returns the text encoded color that I want to apply to the background:

image.png

And this is how the table will look like:

image.png

 

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

 

 

 



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

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. 

 

image.png

Sorry the message is half Spanish half English.

 

Any ideas why?

Thanks for the reply. Actually I should have said it's a live connection not direct query. (SSAS). I cannot pick any measure even when it's a text field. Have you tried doing it via live connection ?

Hey,

 

I can choose measures for conditional formatting in SSAS live connections (SSAS Tabular) no matter if they are defined in the model or created inside the report, report based measures have to be explicity set to datatype text. For this reason I assume you are using SSAS Multidimensional.

 

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

Thank you, it worked !. It was really the measure not being formatted as text in the SSAS model even though it was giving text values. Have fixed it at the source and now its working fine !

Helpful resources

Announcements
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Get Ready for Power BI Dev Camp

Power BI Dev Camp - June 24th

Mark your calendars and join us for our next Power BI Dev Camp!

Top Solution Authors
Top Kudoed Authors