15.5 Data Privacy and Masking Small Cell Sizes

Data privacy is especially important when using Power BI with small cells. One way to return a masked number (e.g. "***") when a cell size is below a certain threshold is to add a calculated measure to your table.

Below are the steps: 1. Go the the table of interest and add a calculated table.

  1. In the code for the calculated measure insert the following code

Calculated Measure = if(
  CALCULATE( DISTINCTCOUNT( Table1[student_id])) <= 5,
  "***",
  CALCULATE( DISTINCTCOUNT( Table1[student_id]), ALL( Table1[student_id])))

This code will calculate a distinct count of the “student_id” field. If the returned code is less or equal to a threshold, in this case five, a value of "***" is returned. In the case that the distinct count is greater than five, the actual count will be returned.

An example of this code in action can be seen in Figure 15.2.

Masked Small Cell Sizes in Power BI

Figure 15.2: Masked Small Cell Sizes in Power BI