Forum Discussion
Update of measures Excel Power Pivot
What you need (I think, although it's a bit difficult to picture exactly what you have here without a sample of the actual)... what you need, I think, is to make use of the INDIRECT function, so that you can change a single cell, off to the side, to contain the month. (10 for October, 11 for November, etc). And then INDIRECT uses that to construct the full formulas in each case.
Here's a useful reference for understanding how INDIRECT can be used.
If you want more help, you can help us help you by posting a copy (or a facsimile, with identifiable/confidential/private data removed) of your spreadsheet on GoogleDrive or OneDrive, and posting a link here granting access.
My table would be as follow. As you can see I have different time period in the same column, different amount depending on the account and account name. That’s why I find it very hard to find a code that would not require to update each month the formulas.
As stated earlier, now I have to use this formula all the time for variance:
Calculate(sum(Expenses[amount], time period =“A2201”) - calculate(sum(Expenses[amount], time period =“B2201”)
And for the % I had to create two different formula which also complicate my formulas
On that divides Actual and Budget and the other one that gives the variation:
Div = Calculate(sum(Expenses[amount], time period =“A2201”)/calculate(sum(Expenses[amount], time period =“B2201”)
And, on another formula
[Div] - 1
TIME PERIÓD AMOUNT ACCOUNT ACCOUNT NAME
A2101 100 PAYROLL WAGES
B2101 250 PAYROLL WAGES
A2201 200 PAYROLL WAGES
B2203 100 RENT MADRID
A2203 430 RENT MADRID
A2103 608 RENT MADRID
A2101 80 PAYROLL PART TIME
B2101 70 PAYROLL PART TIME
A2201 45 PAYROLL PART TIME
B2203 80 RENT BCN
A2203 90 RENT BCN
A2103 56 RENT BCN
Thank you in advance
- SergeiBaklanDec 29, 2022Diamond Contributor
For the current date you may use in parameter
"A" & FORMAT(TODAY(), "yymm")
Or load into the model table "par" with the column "Month" and only one value which is text like "2211". When
"A" & VALUES(par[Month])
Something like
= VAR periodA = "A" & VALUES( par[Month] ) VAR periodB = "B" & VALUES( par[Month] ) VAR sumA = CALCULATE( SUM(Expenses[amount], time period =periodA) VAR sumB = CALCULATE( SUM(Expenses[amount], time period =periodB) RETURN DIVIDE( sumA, sumB, 0 )