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

Dynamic Data Masking

Hello everyone, thank you for your attention,

 

I've been facing a big pain point on my report recently,

 

I'm trying to achieve something i would name like "Dynamic masking"

I'm on a matrix visual and wants to hide information via two criterias : 

-If the number is <5, display NA

-If there is only one row with <5 in the entire column. Assign the value NA to the second littlest value 

 

The objective is to not be able to find the number behind the value <5 by substracting the other values to the total.

The scenario : 
Having a matrix visual like this 

 Year 1
Versicolor10
Virginical7
Viridis4
Total21

 

I want the matrix visual to look like this 

 Year 1
Versicolor10
VirginicalNA
ViridisNA
Total21

 

I tried using this code but didn't achieve what i wanted to do 

Nombre de présents anonymisé =
VAR Total1 = SUM(eTauxReussite[txRssPresents])
VAR Total2 = SUM(eTauxReussite[txRssAdmis])
VAR Count_LessThan5 =
COUNTROWS(
FILTER(
ALLSELECTED(eTauxReussite),
Total1< 5
)
)
VAR IsSingleLessThan5 = Count_LessThan5 = 1
VAR RowRank =
RANKX(
ALLSELECTED(eTauxReussite),
Total1, , ASC
)
VAR ExtraMaskedRow = RowRank = 2
RETURN
IF(
Total1 < 5 &&Total1<>0 || (IsSingleLessThan5 && ExtraMaskedRow)|| Total2<5 && Total2<>0,
"NA",
Total1
)

 

Thank you in advance 

1 ACCEPTED SOLUTION
vojtechsima
Super User
Super User

Hello, @NathanD 
try this (it's prolly overengineered, but have a shot):

measure = 
var _total = SUMX(ALL('Table'[value]), 'Table'[value])
var _value = SUM('Table'[value])
var lessThan5 = COUNTROWS(FILTER('Table', 'Table'[value] < 5))
var lowest = MINX(FILTER(ALL('Table'), 'Table'[value] < 5), 'Table'[value])
var secondLowest = MINX(FILTER(ALL('Table'), 'Table'[value] > lowest), 'Table'[value])
var _twoMore = IF(_value = lowest, "NA", _value)
var _single = IF( _value = lowest || _value = secondLowest, "NA", _value)
var _check = 
SWITCH(
    TRUE(),
    lessThan5 = 1 || ISBLANK(lessThan5) , _single,
    lessThan5 >= 2 || ISBLANK(lessThan5), _twoMore,
    NOT(HASONEVALUE('Table'[name])), _total,
    _value
)

return _check

vojtechsima_0-1730734724431.png

 

View solution in original post

2 REPLIES 2
vojtechsima
Super User
Super User

Hello, @NathanD 
try this (it's prolly overengineered, but have a shot):

measure = 
var _total = SUMX(ALL('Table'[value]), 'Table'[value])
var _value = SUM('Table'[value])
var lessThan5 = COUNTROWS(FILTER('Table', 'Table'[value] < 5))
var lowest = MINX(FILTER(ALL('Table'), 'Table'[value] < 5), 'Table'[value])
var secondLowest = MINX(FILTER(ALL('Table'), 'Table'[value] > lowest), 'Table'[value])
var _twoMore = IF(_value = lowest, "NA", _value)
var _single = IF( _value = lowest || _value = secondLowest, "NA", _value)
var _check = 
SWITCH(
    TRUE(),
    lessThan5 = 1 || ISBLANK(lessThan5) , _single,
    lessThan5 >= 2 || ISBLANK(lessThan5), _twoMore,
    NOT(HASONEVALUE('Table'[name])), _total,
    _value
)

return _check

vojtechsima_0-1730734724431.png

 

Thanks for your answer, i've asked the question poorly and your solution seems right in the environment i provided. 

I'll do make another post to ask the question more deeply

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.

Top Solution Authors