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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Anonymous
Not applicable

Budget Variance - Multiple Slicers

Main Scope

The main idea is to create a price variance between the selected reports, within the selected time frames.

The user of the dashboard will:

1) Select the current budget and period

2) Select the comparing budget and period

 

Data Setup

The sample dataset contains of the following data:

The Main Data:

- Reports (Categorical variable for the different budget)

- DimDate (Date of expected invoicing)

- Net Sales

- Units

 

Besides, I created two seperate tables that are not connected to the Main Data:

Slicer1 = VALUES('Main Data'[Report])
Slicer2 = VALUES('Main Data'[Report])
 
Relationships.png
 
Current Problem:
To create a measure for price variance I will need to create a measure for units and net sales that
1) filters for the selected budget and period in the current period
2) filters the selected budget and period in the comparing period
3) gives the variance of the above selections
 
Initially, I created a measure that filters only the selected budgets based on the selections of the budgets:
Unit = VAR units =
calculate(sum('Total Data Table'[Invoiced Units]),
filter('Total Data Table','Total Data Table'[Report]=SELECTEDVALUE(slicer1[Report]) ||
'Total Data Table'[Report]=SELECTEDVALUE(slicer2[Report])))

RETURN
if(HASONEVALUE('Total Data Table'[Report]),units,
CALCULATE(sum('Total Data Table'[Invoiced Units]), filter('Total Data Table','Total Data Table'[Report]=SELECTEDVALUE(slicer1[Report])))-
CALCULATE(sum('Total Data Table'[Invoiced Units]),filter('Total Data Table','Total Data Table'[Report]=SELECTEDVALUE(slicer2[Report]))))
Variance Without Periods.png
This formula does not filter for the selected period, only the selected budgets.
I would like to compare different budgets accross different periods.
For Example:
- Compare Budget 1 in period 01/01/2019 - 12/03/2019
- To Budget 2 in period 01/07/2019 - 12/09/2019
Try to achieve.png
 
I have tried multiple ways to do this, but have not found any that worked; I hope a smart solutions exists to this issue.
 
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , Please refer these measures set 1- Slicer 1, Sclicer 3 and Set 2 - Slicer 2 and Slicer 4

 

Set 1 =
var _max = maxx(allselected(Slicer3), Slicer3[Date])
var _min = minx(allselected(Slicer3), Slicer3[Date])
return
CALCULATE(sum('Total Data Table'[Invoiced Units]), filter('Total Data Table','Total Data Table'[Report] in allselected(slicer1[Report])
&& 'Total Data Table'[Dimdate] >=_min && 'Total Data Table'[Dimdate] <=_max))


Set 2 =
var _max = maxx(allselected(Slicer4), Slicer4[Date])
var _min = minx(allselected(Slicer4), Slicer4[Date])
return
CALCULATE(sum('Total Data Table'[Invoiced Units]), filter('Total Data Table','Total Data Table'[Report] in allselected(slicer2[Report])
&& 'Total Data Table'[Dimdate] >=_min && 'Total Data Table'[Dimdate] <=_max))

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous , Please refer these measures set 1- Slicer 1, Sclicer 3 and Set 2 - Slicer 2 and Slicer 4

 

Set 1 =
var _max = maxx(allselected(Slicer3), Slicer3[Date])
var _min = minx(allselected(Slicer3), Slicer3[Date])
return
CALCULATE(sum('Total Data Table'[Invoiced Units]), filter('Total Data Table','Total Data Table'[Report] in allselected(slicer1[Report])
&& 'Total Data Table'[Dimdate] >=_min && 'Total Data Table'[Dimdate] <=_max))


Set 2 =
var _max = maxx(allselected(Slicer4), Slicer4[Date])
var _min = minx(allselected(Slicer4), Slicer4[Date])
return
CALCULATE(sum('Total Data Table'[Invoiced Units]), filter('Total Data Table','Total Data Table'[Report] in allselected(slicer2[Report])
&& 'Total Data Table'[Dimdate] >=_min && 'Total Data Table'[Dimdate] <=_max))

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here
Anonymous
Not applicable

@amitchandak Thank you, this helped me out a lot! I created the two sets within a measure with the following formula: 

Total Units =
var set1_max = maxx(allselected(Slicer3), Slicer3[Date])
var set1_min = minx(allselected(Slicer3), Slicer3[Date])
VAR units_set1 = CALCULATE(sum('Total Data Table'[Invoiced Units]), filter('Total Data Table','Total Data Table'[Report] in allselected(slicer1[Report])
&& 'Total Data Table'[Date] >= set1_min && 'Total Data Table'[Date] <= set1_max))

var set2_max = maxx(allselected(Slicer4), Slicer4[Date])
var set2_min = minx(allselected(Slicer4), Slicer4[Date])
VAR units_set2 = CALCULATE(sum('Total Data Table'[Invoiced Units]), filter('Total Data Table','Total Data Table'[Report] in allselected(slicer2[Report])
&& 'Total Data Table'[Date] >= set2_min && 'Total Data Table'[Date] <= set2_max))

VAR Totalunits = calculate(sum('Total Data Table'[Invoiced Units]),FILTER('Total Data Table','Total Data Table'[Report] in allselected(slicer2[Report])
&& 'Total Data Table'[Date] >= set2_min && 'Total Data Table'[Date] <= set2_max ||
'Total Data Table'[Report] in allselected(slicer1[Report])
&& 'Total Data Table'[Date] >= set1_min && 'Total Data Table'[Date] <= set1_max))

RETURN
if(HASONEVALUE('Total Data Table'[Report]),Totalunits,units_set1-units_set2)
 
If I put the amount of units in a table for the selected budget and the selected time periods. Besides, it gives the variance between them.Accepted Solution.pngIt is a beautiful dax code. Again, thank you very much!

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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

Top Solution Authors