Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hey Guys
I've put together the following variable below. It breaks down at the last step because I referenced a variable in the last calculate formula. I sort of understand that why this doesn't work but unsure of how to get it to work. I've seen some peeople put variables inside Calculate or Calculate around the entire variable but its confusing for a DAX n00b such as myself.
Is there a way I can write this (without creating another measure) to get the SCPTotalSiteSales to calculate properly?
Appreciate any help
SCP Equipment Allocation :=
VAR SiteLabourSalesTotal =
IF (
[Labour Sales] <> 0,
CALCULATE (
[Labour Sales],
CostCentre[Facility] = "SCP",
ScopeCodes[ScopeCodeLv2] = "Site"
)
) // This section calculates the total LabourSales for SCP and Site only.
VAR SCPTotalSiteSales =
IF (
[Labour Sales] <> 0,
CALCULATE (
SiteLabourSalesTotal,
REMOVEFILTERS ( Sales ),
REMOVEFILTERS ( ProjectLevel ),
REMOVEFILTERS ( CostCentre ),
REMOVEFILTERS ( ScopeCodes ),
VALUES ( Dates[Month & Year] ),
VALUES ( ScopeCodes[ScopeCodeLv2] )
)
) // THis calculates the total SCP site sales against all the rows
RETURN
SCPTotalSiteSales
Its all good. I figured it out. Just have to embed the variable within a variable.
SCP Equipment Allocation2 =
VAR SCPTotalSiteSales =
IF (
[Labour Sales] <> 0,
CALCULATE (
VAR SiteLabourSalesTotal =
CALCULATE (
[Labour Sales],
CostCentre[Facility] = "SCP NDT Services",
ScopeCodes[ScopeCodeLv2] = "Site"
) // This section calculates the total LabourSales for SCP and Site only.
RETURN
SiteLabourSalesTotal,
REMOVEFILTERS ( Sales ),
REMOVEFILTERS ( ProjectLevel ),
REMOVEFILTERS ( CostCentre ),
REMOVEFILTERS ( ScopeCodes ),
VALUES ( Dates[Month & Year] ),
VALUES ( ScopeCodes[ScopeCodeLv2] )
)
) // THis calculates the total SCP site sales against all the rows
RETURN
SCPTotalSiteSales
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
10 | |
9 | |
8 | |
7 | |
6 |
User | Count |
---|---|
14 | |
13 | |
11 | |
9 | |
8 |