Using Calculation Groups to Desensitise your data for Presentations
Have you ever put together a report that has some really cool functionality and / or you just love the aesthetics and all you want to do is show it off internally to your colleagues... but it contains confidential client information?
I know I have! And who has time these days to create a synthetic dataset that you can plug in? I certainly don't, so you end up missing the opportunity to share that knowledge.
In the following article I'll share with you a quick way to obfuscate data in a report to make it a much quicker process to get it ready for internal presentation.
Please note! You MUST ALWAYS run this passed your client first! In a lot of cases the I.P you're creating belongs solely to the client.
For this example, I'm using this sample dataset provided by Microsoft
And Tabular Editor 2
To create the above we need 3 measures:
Net Sales - A basic measure of net sales
Net Sales =
CALCULATE(
SUM(Sales[Amount])
,Sales[Status] = "Sold"
)
Net Sales (Budget) - An artificial budget I've created for this example
Net Sales (Budget) =
50000 * COUNTROWS('Calendar')
And the % Variance between them
Net Sales Variance (Budget) (%) =
DIVIDE(
[Net Sales]
,[Net Sales (Budget)]
,0)-1
Now that we've got the foundation, we need to apply the calculation group magic!
If you've got Tabular Editor installed, it should turn up in the 'External Tools' ribbon
Fire it up !
Start by creating a new calculation group
Create a new Calculation Item
The Calculation Item:
Recommended by LinkedIn
SELECTEDMEASURE () * DIVIDE ( RANDBETWEEN ( 50, 150 ), 100 )
Once we've created that, save it back to the model, click 'Refresh Now' this will populate the calculation group in the report
You will now see the calculation group in your fields list (Note the cg prefix)
Now you can pull it in to a filter ( Page / Report / Slicer / Any filter works )
No filter:
With Filter
As you can see, all the numbers have changed! But we have a problem, the budget has gone all haywire, remember this is because EVERY measure gets passed through and calculated ( this is something to bear in mind when using Calculation Groups with averages and calculated % )
So back we go to Tabular Editor and we'll create a New Calculation Item
VAR _IfStatic =
CALCULATE ( DIVIDE ( RANDBETWEEN ( 50, 150 ), 100 ), ALL ( 'Calendar' ) )
RETURN
SWITCH (
TRUE()
,CONTAINSSTRING ( SELECTEDMEASURENAME (), "Budget" )
,SELECTEDMEASURE () * _IfStatic
,SELECTEDMEASURE () * DIVIDE ( RANDBETWEEN ( 50, 150 ), 100 )
)
So when we return to the report and refresh, you can see the Budget is now behaving nicely
Please Note! This technique is only useful for obscuring the data for presentations or for screen shots, if you send the PBIX, the data has not been changed in the back end at all, if you show the 'Data' tab on the left-hand ribbon all the data will be actuals!
I hope you've found my technique interesting :)
Please reach out if you have any questions!
If you're looking for some further reading on how calculation groups work, I recommend working your way through this great set of articles
All the time 😀
Nice
Yes, haha
This is a probably great way to present your awesome reports at the Power BI Melbourne Meetup... just saying.