Forum Discussion
Data Bar conditional formatting
- Anonymous1 year ago
Hi Agent47 ,
As danextian said, you need to check a measure first:
Again, you can continue to define the conditional format under each country, and here I've assigned three colors to [Total Profit] equals Maximum Minimum as well as Middle under Canada.
VAR RectColor = SWITCH ( SELECTEDVALUE ( 'financials'[Country] ), "Canada", VAR __vals = CALCULATETABLE ( ADDCOLUMNS ( SUMMARIZE ( 'financials', 'financials'[Country], 'financials'[Product] ), "@TotalProfit", [Total Profit] ), ALLSELECTED ( 'financials'[Product] ) ) VAR __minvalue = MINX ( __vals, [@TotalProfit] ) VAR __maxvalue = MAXX ( __vals, [@TotalProfit] ) VAR __color = SWITCH ( TRUE (), [Total Profit] = __maxvalue, "#06B050", [Total Profit] = __minvalue, "#D41F26", "#3b3a39" ) RETURN __color, "France", "Red", "Germany", "Yellow" )Best Regards,
Gao
Community Support TeamIf there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
Hi Anonymous , what if I need just like 3 different colours for Canada , France , Germany ? No min , max , nothing . Also will I write it as a measure ? And I could not find the measure tools option in my power bi Version: 2.137.751.0 64-bit (October, 2024)
Hi Agent47 ,
As danextian said, you need to check a measure first:
Again, you can continue to define the conditional format under each country, and here I've assigned three colors to [Total Profit] equals Maximum Minimum as well as Middle under Canada.
VAR RectColor =
SWITCH (
SELECTEDVALUE ( 'financials'[Country] ),
"Canada",
VAR __vals =
CALCULATETABLE (
ADDCOLUMNS (
SUMMARIZE ( 'financials', 'financials'[Country], 'financials'[Product] ),
"@TotalProfit", [Total Profit]
),
ALLSELECTED ( 'financials'[Product] )
)
VAR __minvalue =
MINX ( __vals, [@TotalProfit] )
VAR __maxvalue =
MAXX ( __vals, [@TotalProfit] )
VAR __color =
SWITCH (
TRUE (),
[Total Profit] = __maxvalue, "#06B050",
[Total Profit] = __minvalue, "#D41F26",
"#3b3a39"
)
RETURN
__color,
"France", "Red",
"Germany", "Yellow"
)
Best Regards,
Gao
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum