using Calculate inside var

Pris

New Member
Joined
Mar 9, 2021
Messages
4
Office Version
  1. 365
Platform
  1. Windows
Hi, I am relatively new to Power BI
Question : why won't this DAX works in Power BI?

LA Profit =
VAR LACost
CALCULATE([Total Cost],Locations[Location ID]="A132"

VAR LASales
CALCULATE([Total Sales],Locations[Location ID]="A132"
RETURN


It says "The syntax for 'CALCULATE' is incorrect. (DAX(VAR LACost CALCULATE([Total Cost],Locations[Location ID]="A132"VAR LASales CALCULATE([Total Sales],Locations[Location ID]="A132"RETURN))."
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
You need an equal sign after every variable name

Measure name =
var name1 = 1
var name2 = 2
return name1+name2
 
Upvote 0
Solution
Los Angeles Profit =

VAR LASales =
CALCULATE([Total Sales],Locations[Location ID]="A132"

VAR LACost =
CALCULATE([Total Cost],Locations[Location ID]="A132"
RETURN

LASales - LAProfit

Still won't work, it says the same thing
"The syntax for 'VAR' is incorrect. (DAX(VAR LASales = CALCULATE([Total Sales],Locations[Location ID]="A132"VAR LACost= CALCULATE([Total Cost],Locations[Location ID]="A132"RETURNLASales - LAProfit))."
 
Upvote 0
Los Angeles Profit =

VAR LASales =
CALCULATE([Total Sales],Locations[Location ID]="A132"

VAR LACost =
CALCULATE([Total Cost],Locations[Location ID]="A132"
RETURN

LASales - LACost

Still won't work, it says the same thing
"The syntax for 'VAR' is incorrect. (DAX(VAR LASales = CALCULATE([Total Sales],Locations[Location ID]="A132"VAR LACost= CALCULATE([Total Cost],Locations[Location ID]="A132"RETURNLASales - LAProfit))."
 
Upvote 0

Forum statistics

Threads
1,223,723
Messages
6,174,122
Members
452,545
Latest member
boybenqn

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top