Forum Discussion
jhd
7 years agoHelper I
SAMEPERIODLASTYEAR with filter
I have some data which looks like this:
| Financial_Year | Financial_Month | UNITS | TRUE/FALSE |
| FY17 | FM10 | 540 | TRUE |
| FY17 | FM11 | 454 | TRUE |
| FY17 | FM12 | 543 | TRUE |
| FY18 | FM01 | 100 | TRUE |
| FY18 | FM02 | 150 | TRUE |
| FY18 | FM03 | 200 | TRUE |
| FY18 | FM04 | 230 | TRUE |
| FY18 | FM05 | 450 | TRUE |
| FY18 | FM06 | 560 | TRUE |
| FY18 | FM07 | 55 | TRUE |
| FY18 | FM08 | 475 | TRUE |
| FY18 | FM09 | 452 | TRUE |
| FY18 | FM10 | 45 | FALSE |
| FY18 | FM11 | 482 | FALSE |
| FY18 | FM12 | 458 | FALSE |
and I am trying to create a forecast for "UNITS", but only using the values for which TRUE/FALSE = "TRUE"
A moving average would be nice, but I'd be happy with using just the number from the same month in previous year.
To that end, I have created the measure "UNITS_TRUE":
=CALCULATE(SUM(UNITS),FILTER(TRUE/FALSE)="TRUE")
which gives me:
| Financial_Year | Financial_Month | UNITS | TRUE/FALSE | UNITS_TRUE |
| FY17 | FM10 | 540 | TRUE | 540 |
| FY17 | FM11 | 454 | TRUE | 454 |
| FY17 | FM12 | 543 | TRUE | 543 |
| FY18 | FM01 | 100 | TRUE | 100 |
| FY18 | FM02 | 150 | TRUE | 150 |
| FY18 | FM03 | 200 | TRUE | 200 |
| FY18 | FM04 | 230 | TRUE | 230 |
| FY18 | FM05 | 450 | TRUE | 450 |
| FY18 | FM06 | 560 | TRUE | 560 |
| FY18 | FM07 | 55 | TRUE | 55 |
| FY18 | FM08 | 475 | TRUE | 475 |
| FY18 | FM09 | 452 | TRUE | 452 |
| FY18 | FM10 | 45 | FALSE | |
| FY18 | FM11 | 482 | FALSE | |
| FY18 | FM12 | 458 | FALSE |
and i am now trying to use SAMEPERIODLASTYEAR to get:
| Financial_Year | Financial_Month | UNITS | TRUE/FALSE | UNITS_TRUE | UNITS_LASTYEAR |
| FY17 | FM10 | 540 | TRUE | 540 | |
| FY17 | FM11 | 454 | TRUE | 454 | |
| FY17 | FM12 | 543 | TRUE | 543 | |
| FY18 | FM01 | 100 | TRUE | 100 | |
| FY18 | FM02 | 150 | TRUE | 150 | |
| FY18 | FM03 | 200 | TRUE | 200 | |
| FY18 | FM04 | 230 | TRUE | 230 | |
| FY18 | FM05 | 450 | TRUE | 450 | |
| FY18 | FM06 | 560 | TRUE | 560 | |
| FY18 | FM07 | 55 | TRUE | 55 | |
| FY18 | FM08 | 475 | TRUE | 475 | |
| FY18 | FM09 | 452 | TRUE | 452 | |
| FY18 | FM10 | 45 | FALSE | 540 | |
| FY18 | FM11 | 482 | FALSE | 454 | |
| FY18 | FM12 | 458 | FALSE | 543 |
However,
CALCULATE(SUM(UNITS),
FILTER(TRUE/FALSE)="TRUE",
SAMEPERIODLASTYEAR('CALENDAR'[DATE]))
does not work, I just get blanks.
Can anyone give me some pointers please?
Thanks, James
4 Replies
- ryan_mayuSuper User
Could you please provide more detailed info? I tried this and it works on my end. You can refer to my coding.
test = var a= CALCULATE(SUM(Sheet31[amount]),SAMEPERIODLASTYEAR('Table'[Date])) return if (SELECTEDVALUE(Sheet31[true/false])="True",a) - v-jiascu-msftMicrosoft Employee
