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

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. 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

 






Any kudos or recognition appreciated. To learn more on the topic, check out my blog and follow me on LinkedIn.

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

 






Any kudos or recognition appreciated. To learn more on the topic, check out my blog and follow me on LinkedIn.

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
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.