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
Dhuey
Regular Visitor

Highlighting slicer results in matrix help

Hi all

 

Long time watcher, first time poster. I am a teacher who is beginning learning how to use PowerBI. I wish to be able to display my student results in a more aesthetically pleasing way (hence, learning PowerBI).

 

I have included a dummy file of where I am up to below.

 

I am wanting to be able to select a students name and have their result highlight in the Matrix (not filter/slice other data out of the matrix). I know I can do this in Excel with a conditonal format lookup (I have done it there before), but am wondering if it is possible to do it in PowerBI. 

 

Here is what I want:

 

Capture.JPG

 

I have included my data below:

 

https://1drv.ms/u/s!ApsxXn-MGjNCftks6yoGbIjR_Rs?e=lkJ4Oy  (PowerBi file)

https://1drv.ms/x/s!ApsxXn-MGjNCf_VHgWvvZigiPYI?e=no7AC4 (Excel source file)

 

Thanks in advance to anyone reads this far down, and even larger thanks to anyone who has ideas/solution to this.

 

Paul

2 ACCEPTED SOLUTIONS
DataInsights
Super User
Super User

@Dhuey,

 

Here's an alternative approach that enables you to avoid creating a copy of your table.

 

Create measures:

 

Result Count = COUNT ( 'Yr7 data'[Result] )

Result Count All = CALCULATE ( [Result Count], ALL ( 'Yr7 data'[Student Name] ) )

Result Count Student = 
VAR vStudent =
    ALLSELECTED ( 'Yr7 data'[Student Name] )
VAR vStudentResultCount =
    CALCULATE ( [Result Count], 'Yr7 data'[Student Name] = vStudent )
VAR vResult =
    IF ( NOT ISBLANK ( vStudentResultCount ), "#f4f142" )
RETURN
    vResult

 

Note: you can change the color by changing "#f4f142" to the desired color.

 

In the matrix, the Values should be [Result Count All].

 

Set conditional formatting in [Result Count All]:

 

DataInsights_0-1607897449713.png

 

Result:

 

DataInsights_1-1607897493060.png

 

DataInsights_2-1607897512937.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

v-deddai1-msft
Community Support
Community Support

Hi @Dhuey ,

 

Here is a little modification of DataInsights's reply when you try to multi-select student name in slicer or with no selection in slicer. 

 

You can add the following measure in your background color based on field:

Measure =
VAR a =
    CALCULATE (
        COUNT ( 'Yr7 data'[Result] ),
        'Yr7 data'[Student Name] IN VALUES ( 'Yr7 data'[Student Name] )
    )
RETURN
    IF (
        ISFILTERED ( 'Yr7 data'[Student Name] ),
        IF ( ISBLANK ( a ), BLANK (), "Yellow" ),
        BLANK ()
    )

 

For more details, please refer to the pbix file: https://qiuyunus-my.sharepoint.com/:u:/g/personal/pbipro_qiuyunus_onmicrosoft_com/EXGMeGpHdrlBmsFV2D...

 

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

 

Best Regards,

Dedmon Dai

 

View solution in original post

5 REPLIES 5
Dhuey
Regular Visitor

@AllisonKennedy  @DataInsights  @v-deddai1-msft 

 

Thank you all so much for your insights and help. I can't wait to test this with real data across all year levels, will certainly help out at parent conferences.

 

Dhuey

v-deddai1-msft
Community Support
Community Support

Hi @Dhuey ,

 

Here is a little modification of DataInsights's reply when you try to multi-select student name in slicer or with no selection in slicer. 

 

You can add the following measure in your background color based on field:

Measure =
VAR a =
    CALCULATE (
        COUNT ( 'Yr7 data'[Result] ),
        'Yr7 data'[Student Name] IN VALUES ( 'Yr7 data'[Student Name] )
    )
RETURN
    IF (
        ISFILTERED ( 'Yr7 data'[Student Name] ),
        IF ( ISBLANK ( a ), BLANK (), "Yellow" ),
        BLANK ()
    )

 

For more details, please refer to the pbix file: https://qiuyunus-my.sharepoint.com/:u:/g/personal/pbipro_qiuyunus_onmicrosoft_com/EXGMeGpHdrlBmsFV2D...

 

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

 

Best Regards,

Dedmon Dai

 

AllisonKennedy
Super User
Super User

@DataInsights Yes, that is a better solution, I just went with the fact that duplicate table was already created, but much more efficient to just use a duplicate measure. 


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

DataInsights
Super User
Super User

@Dhuey,

 

Here's an alternative approach that enables you to avoid creating a copy of your table.

 

Create measures:

 

Result Count = COUNT ( 'Yr7 data'[Result] )

Result Count All = CALCULATE ( [Result Count], ALL ( 'Yr7 data'[Student Name] ) )

Result Count Student = 
VAR vStudent =
    ALLSELECTED ( 'Yr7 data'[Student Name] )
VAR vStudentResultCount =
    CALCULATE ( [Result Count], 'Yr7 data'[Student Name] = vStudent )
VAR vResult =
    IF ( NOT ISBLANK ( vStudentResultCount ), "#f4f142" )
RETURN
    vResult

 

Note: you can change the color by changing "#f4f142" to the desired color.

 

In the matrix, the Values should be [Result Count All].

 

Set conditional formatting in [Result Count All]:

 

DataInsights_0-1607897449713.png

 

Result:

 

DataInsights_1-1607897493060.png

 

DataInsights_2-1607897512937.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




AllisonKennedy
Super User
Super User

@Dhuey  This was a fun example. See the attached file under my signature. I created a measure to calculate the student results, using your copy unrelated table: 

Count Result = IF(HASONEVALUE('Yr7 data'[Student Name]), COUNTROWS(FILTER('Yr7 data copy', 'Yr7 data copy'[Student Code] = SELECTEDVALUE('Yr7 data'[Student Code]))), 0)
 
Then put conditional formatting on the top chart using that measure.
 
Hope it helps, let me know if you have any questions on what I did. Just @ me as notifications aren't working great in this forum at the moment. 😄

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

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.