Forum Discussion
Same column calculation with condition in another column
- 4 years ago
Anonymous , Create a date column
date = eomonth(date([year], [month], 1),0)
then create a new column
last month Cost =
var _last = eomonth([Date],-1)
return
[cost] - maxx(filter(Table, [Product] = earlier([Product]) && eomonth([Date],0) = _last) , [Cost])
Anonymous , Create a date column
date = eomonth(date([year], [month], 1),0)
then create a new column
last month Cost =
var _last = eomonth([Date],-1)
return
[cost] - maxx(filter(Table, [Product] = earlier([Product]) && eomonth([Date],0) = _last) , [Cost])
Hi amitchandak
I have another question relating the original one. I would like to know how to calculate the quartely difference per Product like below. The 1st quarter is from April to Jun, and the 2nd quarter starts from Jul. I am looking for a solution to calculate the difference of quartely aggregated cost per product. I would appreciate if you provide a sample DAX code. Thanks.
| Year | Month | Product | Cost | Cost difference from last quarter (Required result) |
| 2022 | 4 | A | 10 | 0 |
| 2022 | 4 | B | 20 | 0 |
| 2022 | 5 | A | 10 | 0 |
| 2022 | 5 | B | 20 | 0 |
| 2022 | 6 | A | 10 | 0 |
| 2022 | 6 | B | 20 | 0 |
| 2022 | 7 | A | 15 | 15 |
| 2022 | 7 | B | 25 | -10 |
| 20222 | 8 | A | 15 | 15 |
| 2022 | 8 | B | 25 | -10 |
| 2022 | 9 | A | 15 | 15 |