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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
vin26
Resolver I
Resolver I

Apply Colors to selected range in matrix

Hello,

I need a help in creating table with custom color selection. My requirement is to create a table or matrix, in which user should be able select range and apply the color on selected range. Below is the example:

Screenshot_PBI.JPG

Please let me know is there any way to achieve above requirement and also please suggest any other way to represent data in similar way.

1 ACCEPTED SOLUTION

Hi @vin26 ,

 

We can try to create ten calculated table first as the range:

 

For Rows:

 

C_Red_Row = DISTINCT('Table'[Row])

 

 

 

C_Yellow_Row = DISTINCT('Table'[Row])

 

 

 

C_Green_Row = DISTINCT('Table'[Row])

 

 

 

C_Blue_Row = DISTINCT('Table'[Row])

 

 

 

C_Gray_Row = DISTINCT('Table'[Row])

 

 

For Columns:

 

C_Red_Col = DISTINCT('Table'[Column])

 

 

 

C_Yellow_Col = DISTINCT('Table'[Column])

 

 

 

C_Green_Col = DISTINCT('Table'[Column])

 

 

 

C_Blue_Col = DISTINCT('Table'[Column])

 

 

 

C_Gray_Col = DISTINCT('Table'[Column])

 

 

Then we can create a measure as Filed Value of conditional format:

 

Measure:

 

Color Measure = 
SWITCH (
    TRUE (),
    MIN ( 'Table'[Row] ) IN DISTINCT ( C_Red_Row[Row] )
        && MIN ( 'Table'[Column] ) IN DISTINCT ( C_Red_Col[Column] ), "#FF0000",
    MIN ( 'Table'[Row] ) IN DISTINCT ( C_Yellow_Row[Row] )
        && MIN ( 'Table'[Column] ) IN DISTINCT ( C_Yellow_Col[Column] ), "#FFFF00",
    MIN ( 'Table'[Row] ) IN DISTINCT ( C_Green_Row[Row] )
        && MIN ( 'Table'[Column] ) IN DISTINCT ( C_Green_Col[Column] ), "#00FF00",
    MIN ( 'Table'[Row] ) IN DISTINCT ( C_Blue_Row[Row] )
        && MIN ( 'Table'[Column] ) IN DISTINCT ( C_Blue_Col[Column] ), "#0000FF",
    MIN ( 'Table'[Row] ) IN DISTINCT ( C_Gray_Row[Row] )
        && MIN ( 'Table'[Column] ) IN DISTINCT ( C_Gray_Col[Column] ), "#D0D0D0"
)

 

 

Please remember to close the interactions between different slicers so that you can choose value smoothly

 

10.jpg

 


If it doesn't meet your requirement, Could you please show the exact expected result based on the tables that we have shared?


By the way, PBIX file as attached.


Best regards,

 

Community Support Team _ Dong Li
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

5 REPLIES 5
Greg_Deckler
Super User
Super User

Right, so you would have to create a measure that would take those slicer values and return a number indicator for a color. You would use this measure in your conditional formatting rules.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Thanks Greg, Yes, you are right. I am trying to create the measure to get the all the slicer selections into one measure, somewhat it is not working. Could you please suggest idea?

Hi @vin26 ,

 

We can try to create ten calculated table first as the range:

 

For Rows:

 

C_Red_Row = DISTINCT('Table'[Row])

 

 

 

C_Yellow_Row = DISTINCT('Table'[Row])

 

 

 

C_Green_Row = DISTINCT('Table'[Row])

 

 

 

C_Blue_Row = DISTINCT('Table'[Row])

 

 

 

C_Gray_Row = DISTINCT('Table'[Row])

 

 

For Columns:

 

C_Red_Col = DISTINCT('Table'[Column])

 

 

 

C_Yellow_Col = DISTINCT('Table'[Column])

 

 

 

C_Green_Col = DISTINCT('Table'[Column])

 

 

 

C_Blue_Col = DISTINCT('Table'[Column])

 

 

 

C_Gray_Col = DISTINCT('Table'[Column])

 

 

Then we can create a measure as Filed Value of conditional format:

 

Measure:

 

Color Measure = 
SWITCH (
    TRUE (),
    MIN ( 'Table'[Row] ) IN DISTINCT ( C_Red_Row[Row] )
        && MIN ( 'Table'[Column] ) IN DISTINCT ( C_Red_Col[Column] ), "#FF0000",
    MIN ( 'Table'[Row] ) IN DISTINCT ( C_Yellow_Row[Row] )
        && MIN ( 'Table'[Column] ) IN DISTINCT ( C_Yellow_Col[Column] ), "#FFFF00",
    MIN ( 'Table'[Row] ) IN DISTINCT ( C_Green_Row[Row] )
        && MIN ( 'Table'[Column] ) IN DISTINCT ( C_Green_Col[Column] ), "#00FF00",
    MIN ( 'Table'[Row] ) IN DISTINCT ( C_Blue_Row[Row] )
        && MIN ( 'Table'[Column] ) IN DISTINCT ( C_Blue_Col[Column] ), "#0000FF",
    MIN ( 'Table'[Row] ) IN DISTINCT ( C_Gray_Row[Row] )
        && MIN ( 'Table'[Column] ) IN DISTINCT ( C_Gray_Col[Column] ), "#D0D0D0"
)

 

 

Please remember to close the interactions between different slicers so that you can choose value smoothly

 

10.jpg

 


If it doesn't meet your requirement, Could you please show the exact expected result based on the tables that we have shared?


By the way, PBIX file as attached.


Best regards,

 

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Is there any way to summarize the values up by color (Total or Orange, Total of Green.. etc.)?, I have been trying to replicate the measure and trying to create a summarized table, unfortunately matrix is not allowing me to drop measure to rows or column.

@v-lid-msft Amazing!, you are fantastic, it works. Thanks a lot for the solution!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.