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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
BBIUser
Helper IV
Helper IV

Dynamic text based on masked data in the table

Hello,

 

I need to create a dynamic text based on few masked data which is already in the table.

Sample Data:

BBIUser_0-1710689775446.png

I have created a measure to not to show the data on the bar charts based on the filters created in DAX.
MaskedData = COUNTROWS(FILTER(
'Table1', 'Table1'[Employee Count] <> 0 &&
'Table1'[Masked] <> "Yes"))

When the bar chart doesn't show the data, the text should show 'Data Masked' in a card or anyother visual
and when the employee count>1 and Masked=No, then card visual text should be hidden. 

Can I do this in DAX similar to the above? What is the DAX for this to make it work?

 

Thank you.

 

 

1 ACCEPTED SOLUTION

Update the measure as following...

DisplayMessage = 
VAR EmployeeCountMoreThanOne = CALCULATE(COUNTROWS('Sheet1'), 'Sheet1'[Employee Count] > 1)
VAR IsAnyRowMasked = CALCULATE(MAXX('Sheet1', IF('Sheet1'[Masked] = "Yes", 1, 0)), ALLSELECTED('Sheet1')) = 1
RETURN
    IF(EmployeeCountMoreThanOne > 0 && NOT IsAnyRowMasked, "Data Masked", BLANK())




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

5 REPLIES 5
BBIUser
Helper IV
Helper IV

@amustafa Thank you! It works.

@Ashish_Mathur DAX that you gave me doesn't fit the solution. amustafa solution worked correctly. Appreciate your reply!

Ashish_Mathur
Super User
Super User

Hi,

Does this work by any chance?

MaskedData = COALESCE(COUNTROWS(FILTER('Table1', 'Table1'[Employee Count] <> 0 &&'Table1'[Masked] <> "Yes")),"Data Masked")

Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
amustafa
Super User
Super User

Create a measure as following..

 

DisplayMessage = 
VAR EmployeeCountMoreThanOne = CALCULATE(COUNTROWS('Table1'), 'Table1'[Employee Count] > 1)
VAR IsMasked = CALCULATE(MAX('Table1'[Masked]), ALL('Table1')) = "No"
RETURN
    IF(EmployeeCountMoreThanOne > 0 && IsMasked, BLANK(), "Data Masked")

 

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




@amustafa Appreciate your reply!

The card value is not changing to 'Blank' when the filters are changed to Race in Group Category. None of the values under Race are Masked. So, the card should not show 'Data Masked'. 

I tried attaching the .pbix file for troubleshoot.

https://drive.google.com/file/d/15NSWkqo6bPDhZZPIUwq-V2ZwuEUfXMXm/view?usp=drive_link

 

Update the measure as following...

DisplayMessage = 
VAR EmployeeCountMoreThanOne = CALCULATE(COUNTROWS('Sheet1'), 'Sheet1'[Employee Count] > 1)
VAR IsAnyRowMasked = CALCULATE(MAXX('Sheet1', IF('Sheet1'[Masked] = "Yes", 1, 0)), ALLSELECTED('Sheet1')) = 1
RETURN
    IF(EmployeeCountMoreThanOne > 0 && NOT IsAnyRowMasked, "Data Masked", BLANK())




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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