Forum Discussion
previous year filter
- 9 years ago
According to this document, VAR Function (DAX) is included in SQL Server 2016 Analysis Services (SSAS), Power Pivot in Excel 2016, and Power BI Desktop.
You should be able to use following measure formula with Power Pivot in Excel 2016.
PY Balance = VAR PY = CALCULATE ( MAX ( GL_ACCOUNT_BALANCES1[CURRENT_YEAR] ), ALLSELECTED ( GL_ACCOUNT_BALANCES1 ) ) - 1 RETURN ( CALCULATE ( SUM ( GL_ACCOUNT_BALANCES1[Value] ), FILTER ( ALL ( GL_ACCOUNT_BALANCES1[ACCOUNT_IDENT] ), GL_ACCOUNT_BALANCES1[ACCOUNT_IDENT] = "Actual" ), FILTER ( ALL ( GL_ACCOUNT_BALANCES1[CURRENT_YEAR] ), GL_ACCOUNT_BALANCES1[CURRENT_YEAR] = PY ) ) )Best Regards,
Herbert
So if I understand; the top statement works - with 2015 manually entered into the statement.
The bottom statement is the same but you want to use a variable [PY]
Did you declare [PY] as a variable?
- Drobinson19 years agoHelper III
Correct,
Didnt seem like I was able to decalre a variable since it was a measure? - CahabaData9 years agoMemorable Member
I would try opening your measure the variable declaration:
YourMeasure = VAR
[PY]=CALCULATE(MAX(GL_ACCOUNT_BALANCES1[CURRENT_YEAR]),ALLSELECTED(GL_ACCOUNT_BALANCES1))-1
RETURN
CALCULATE ( ....your 2nd statement.....
- Drobinson19 years agoHelper III
I am using powerpivot in excel. VAR does not seem to be an option?
- Drobinson19 years agoHelper III
I am using powerpivot in excel and it does not seem like var works for measures.
- v-haibl-msft9 years agoMicrosoft Employee
According to this document, VAR Function (DAX) is included in SQL Server 2016 Analysis Services (SSAS), Power Pivot in Excel 2016, and Power BI Desktop.
You should be able to use following measure formula with Power Pivot in Excel 2016.
PY Balance = VAR PY = CALCULATE ( MAX ( GL_ACCOUNT_BALANCES1[CURRENT_YEAR] ), ALLSELECTED ( GL_ACCOUNT_BALANCES1 ) ) - 1 RETURN ( CALCULATE ( SUM ( GL_ACCOUNT_BALANCES1[Value] ), FILTER ( ALL ( GL_ACCOUNT_BALANCES1[ACCOUNT_IDENT] ), GL_ACCOUNT_BALANCES1[ACCOUNT_IDENT] = "Actual" ), FILTER ( ALL ( GL_ACCOUNT_BALANCES1[CURRENT_YEAR] ), GL_ACCOUNT_BALANCES1[CURRENT_YEAR] = PY ) ) )Best Regards,
Herbert