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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

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
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.