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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Vashko
Frequent Visitor

Conditional formatting across 4 measures

Hello all,

I have a bit strange request so I will lay out the problem as best as I can.

Basically the idea is to have gradient applied from left to right instead of from top to bottom, but the issue is the columns are 4 seperate measures. 

 

Does anybody have any pointers for me?

 

Vashko_0-1686734658851.png
Thanks in advance

 

1 ACCEPTED SOLUTION
v-yueyunzh-msft
Community Support
Community Support

Hi, @Vashko 

According to your description, you want to " have gradient applied from left to right instead of from top to bottom, but the issue is the columns are 4 seperate measures."

Because our default color format is for the entire table; so this can be a little complicated, you can refer to.

Here are the steps you can refer to :
(1)This is my test data:

vyueyunzhmsft_0-1686902658005.png

(2)We need to create a new table as a dimension table like this('Table 2'):

vyueyunzhmsft_1-1686902695726.png

(3)Then we need to create two measures like this:

Value Measure = VAR _t=ADDCOLUMNS( SUMMARIZE(ALLSELECTED('Table'),'Table'[Category],'Table'[SubCategory]) , "QTD" , [QTD Measure] ,"6 Mth" , [6 Month Measure],
 "12 Mth" , [12 Month Measure] , "2Yr" , [2Yr Measure])
 var _cur_column =  MAX('Table2'[Column1])
 var _cat = VALUES('Table'[Category])
 var _sub = VALUES( 'Table'[SubCategory])
 var _t2= FILTER( _t,  [Category] in  _cat && [SubCategory] in  _sub)
 return
 SWITCH( _cur_column , 
 "QTD" ,  SUMX(_t2, [QTD]),
 "6Mth",SUMX(_t2, [6 Mth]),
 "12Mth",SUMX(_t2, [12 Mth]),
 "2Yr",SUMX(_t2, [2Yr])
 )
Measure /Color = VAR _t=ADDCOLUMNS( SUMMARIZE(ALLSELECTED('Table'),'Table'[Category],'Table'[SubCategory]) , "QTD" , [QTD Measure] ,"6 Mth" , [6 Month Measure],
 "12 Mth" , [12 Month Measure] , "2Yr" , [2Yr Measure])
 var _cat= VALUES('Table'[Category])
 var _sub = VALUES('Table'[SubCategory])
var _t2= FILTER( _t , [Category] in _cat && [SubCategory]  in _sub)
var _list = {sumx(_t2 , [QTD]),SUMX(_t2 ,[6 Mth]), sumx(_t2, [12 Mth]),SUMX(_t2,[2Yr])}
var _value_measure=  [Value Measure]
var _rank =COUNTROWS( DISTINCT( FILTER(_list, [Value] <_value_measure)))+1
 var _column_count = COUNTROWS(ALL('Table2'))
 var _percentage=_rank/_column_count
 return
 "rgba(80,210,170,"&_percentage&")"

 

(4)Then we can put the [Value Measure] on the visual and we need to configure the [Measure /Color] as the format:

vyueyunzhmsft_2-1686902777272.png

The result is as follows:

vyueyunzhmsft_3-1686902790259.png

 

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

1 REPLY 1
v-yueyunzh-msft
Community Support
Community Support

Hi, @Vashko 

According to your description, you want to " have gradient applied from left to right instead of from top to bottom, but the issue is the columns are 4 seperate measures."

Because our default color format is for the entire table; so this can be a little complicated, you can refer to.

Here are the steps you can refer to :
(1)This is my test data:

vyueyunzhmsft_0-1686902658005.png

(2)We need to create a new table as a dimension table like this('Table 2'):

vyueyunzhmsft_1-1686902695726.png

(3)Then we need to create two measures like this:

Value Measure = VAR _t=ADDCOLUMNS( SUMMARIZE(ALLSELECTED('Table'),'Table'[Category],'Table'[SubCategory]) , "QTD" , [QTD Measure] ,"6 Mth" , [6 Month Measure],
 "12 Mth" , [12 Month Measure] , "2Yr" , [2Yr Measure])
 var _cur_column =  MAX('Table2'[Column1])
 var _cat = VALUES('Table'[Category])
 var _sub = VALUES( 'Table'[SubCategory])
 var _t2= FILTER( _t,  [Category] in  _cat && [SubCategory] in  _sub)
 return
 SWITCH( _cur_column , 
 "QTD" ,  SUMX(_t2, [QTD]),
 "6Mth",SUMX(_t2, [6 Mth]),
 "12Mth",SUMX(_t2, [12 Mth]),
 "2Yr",SUMX(_t2, [2Yr])
 )
Measure /Color = VAR _t=ADDCOLUMNS( SUMMARIZE(ALLSELECTED('Table'),'Table'[Category],'Table'[SubCategory]) , "QTD" , [QTD Measure] ,"6 Mth" , [6 Month Measure],
 "12 Mth" , [12 Month Measure] , "2Yr" , [2Yr Measure])
 var _cat= VALUES('Table'[Category])
 var _sub = VALUES('Table'[SubCategory])
var _t2= FILTER( _t , [Category] in _cat && [SubCategory]  in _sub)
var _list = {sumx(_t2 , [QTD]),SUMX(_t2 ,[6 Mth]), sumx(_t2, [12 Mth]),SUMX(_t2,[2Yr])}
var _value_measure=  [Value Measure]
var _rank =COUNTROWS( DISTINCT( FILTER(_list, [Value] <_value_measure)))+1
 var _column_count = COUNTROWS(ALL('Table2'))
 var _percentage=_rank/_column_count
 return
 "rgba(80,210,170,"&_percentage&")"

 

(4)Then we can put the [Value Measure] on the visual and we need to configure the [Measure /Color] as the format:

vyueyunzhmsft_2-1686902777272.png

The result is as follows:

vyueyunzhmsft_3-1686902790259.png

 

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.