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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

How to mask values in a pie chart based on powerquery measure context

Hi all,

i'm managin a report about employeee assesment so data under privacy restriction.

one of the rule is that the report should mask values in case of usere select a group of less than 5 employee.

the basic chart is a pie showing how many competencies managers marked as ok/nok (value 1 or 0 in ManagerOk column)

mpona_0-1711782655708.png

 so i created a powerquery measure

5+SelectedEmployee = IF(DISTINCTCOUNT(HRAssesment[Employee ID])>=5,"ok","nok")
and a new column with maskedvalue at 100
mpona_1-1711782997833.png

i'm trying now to use switch function to create a MaskedMAnager
 
MaskedManagerOK =
SWITCH([5+SelectedEmployee],
                    "ok",'HRAssesment'[ManagerOk],
                    "nok",'HRAssesment'[MaskedValue]
                    )
and assign as legend in a pie chart
but the pie chart read the power query always as "nok" i guess because it read the value of "5+SelectedEmployee" in the table context for each row and in the selection context of pie chart.
mpona_0-1711783901151.png

title of this chart represent the value of the power query measure 5+SelectedEmployee. 

if ok it should give ok/nok chart

mpona_1-1711783994661.png

 


any suggestion?
 
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi, @Anonymous 


Thank you very much for @lbendlin suggestion, based on my testing I think it's something wrong with the Measure you wrote, it doesn't return ok/nok you can refer to the following measure.

 

vyaningymsft_0-1711952427653.png

vyaningymsft_1-1711952439797.png

 

New 5+SelectedEmployee = 
VAR _result =
    CALCULATE (
        COUNTROWS ( HRAssesment ),
        FILTER ( HRAssesment, DISTINCTCOUNT ( HRAssesment[Employee ID] ) )
    )
RETURN
    IF ( _result >= 8, "ok", "nok" )

 

Best Regards,
Yang
Community Support Team

 

If this does not work, could you please share some sample data without sensitive information and expected output.

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

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi, @Anonymous 


Thank you very much for @lbendlin suggestion, based on my testing I think it's something wrong with the Measure you wrote, it doesn't return ok/nok you can refer to the following measure.

 

vyaningymsft_0-1711952427653.png

vyaningymsft_1-1711952439797.png

 

New 5+SelectedEmployee = 
VAR _result =
    CALCULATE (
        COUNTROWS ( HRAssesment ),
        FILTER ( HRAssesment, DISTINCTCOUNT ( HRAssesment[Employee ID] ) )
    )
RETURN
    IF ( _result >= 8, "ok", "nok" )

 

Best Regards,
Yang
Community Support Team

 

If this does not work, could you please share some sample data without sensitive information and expected output.

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

lbendlin
Super User
Super User

You cannot mask data after the fact.  You need to base your entire solution on pre-masked data.

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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