Forum Discussion
Conditional Formatting with IF statement
- 3 years ago
I'll do the best I can with the info provided...
BIG PICTURE, this is what you want to do, ASSUMING the social media company is going to be in the visual, and ASSUMING it's going to be something like a table visual....
Create a measure that returns a value like 0,1,2,3 etc depending on the conditions and the colors you want. Maybe 0 will be red, 1 will be green, 2 will be orange, 3 will be blue. Idk, whatever you want.
Note that this works because the switch statement stops evaluating once it reaches a statement that resolves to TRUE().
Conditional_Format_color =
var engagement = [engagement rate]
var media_company = SELECTEDVALUE(TABLE[Social_Media_Company])
RETURN
SWITCH(
TRUE(),
media_company = "Facebook" && engagement < 0.005, 1,
media_company = "Facebook", 0
----continue adding companies and return values here
)
Now, once you have done that, format the [Engagement Rate] field in your visual using the field value [Conditional_Format_color]. Just map each number to the corresponding color using the "Rules" you want, and voila.
//Mediocre Power BI Advice, but it's free//
I'll do the best I can with the info provided...
BIG PICTURE, this is what you want to do, ASSUMING the social media company is going to be in the visual, and ASSUMING it's going to be something like a table visual....
Create a measure that returns a value like 0,1,2,3 etc depending on the conditions and the colors you want. Maybe 0 will be red, 1 will be green, 2 will be orange, 3 will be blue. Idk, whatever you want.
Note that this works because the switch statement stops evaluating once it reaches a statement that resolves to TRUE().
Conditional_Format_color =
var engagement = [engagement rate]
var media_company = SELECTEDVALUE(TABLE[Social_Media_Company])
RETURN
SWITCH(
TRUE(),
media_company = "Facebook" && engagement < 0.005, 1,
media_company = "Facebook", 0
----continue adding companies and return values here
)
Now, once you have done that, format the [Engagement Rate] field in your visual using the field value [Conditional_Format_color]. Just map each number to the corresponding color using the "Rules" you want, and voila.
//Mediocre Power BI Advice, but it's free//