Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
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 | |
| Versicolor | 10 |
| Virginical | 7 |
| Viridis | 4 |
| Total | 21 |
I want the matrix visual to look like this
| Year 1 | |
| Versicolor | 10 |
| Virginical | NA |
| Viridis | NA |
| Total | 21 |
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
Solved! Go to Solution.
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
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
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
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 143 | |
| 124 | |
| 101 | |
| 80 | |
| 55 |