Forum Discussion
partial month calculation
| year | month | amount | year | month | amount | |||
| 2017 | 1 | 1000 | 2017 | 1 | 1000 | |||
| 2017 | 2 | 3000 | 2017 | 2 | 2000 | |||
| 2017 | 3 | 7000 | wanted result-> | 2017 | 3 | 4000 | ||
| 2017 | 4 | 10000 | 2017 | 4 | 3000 | |||
| 2017 | 5 | 14000 | 2017 | 5 | 4000 | |||
| 2017 | 6 | 18000 | 2017 | 6 | 4000 | |||
| 2017 | 7 | 25000 | 2017 | 7 | 7000 | |||
| 2017 | 8 | 30000 | 2017 | 8 | 5000 | |||
| 2017 | 9 | 40000 | 2017 | 9 | 10000 | |||
| 2017 | 10 | 75000 | 2017 | 10 | 35000 | |||
| 2017 | 11 | 95000 | 2017 | 11 | 20000 | |||
| 2017 | 12 | 100000 | 2017 | 12 | 5000 | |||
| 2018 | 1 | 2000 | 2018 | 1 | 2000 | |||
| 2018 | 2 | 3000 | 2018 | 2 | 1000 | |||
| 2018 | 3 | 5000 | 2018 | 3 | 2000 | |||
| 2018 | 4 | 7000 | 2018 | 4 | 2000 | |||
| 2018 | 5 | 10000 | 2018 | 5 | 3000 | |||
| 2018 | 6 | 12000 | 2018 | 6 | 2000 | |||
| 2018 | 7 | 15000 | 2018 | 7 | 5000 | |||
| 2018 | 8 | 19000 | 2018 | 8 | 4000 | |||
| 2018 | 9 | 30000 | 2018 | 9 | 11000 | |||
| 2018 | 10 | 40000 | 2018 | 10 | 10000 | |||
| 2018 | 11 | 45000 | 2018 | 11 | 5000 | |||
| 2018 | 12 | 50000 | 2018 | 12 | 5000 |
given the example on the right this is how my data are stored in table
on the left the result that i wanted :)
i need to calculate for each month in the year the partial (result= month amount- prev month amount) from jannuar to dicember and every year restart
Hi Anonymous,
Maybe you could try to modify the formula as below:
Column = VAR a = 'Table1'[month] - 1 RETURN [amount] - CALCULATE ( SUM ( Table1[amount] ), FILTER ( 'Table1', 'Table1'[month] = a && 'Table1'[year] = EARLIER ( Table1[year] ) && 'Table1'[code] = EARLIER ( Table1[code] ) && 'Table1'[company] = "dk" ) )Regards,
Daniel He
9 Replies
- Vishnu_1980Frequent Visitor
Hi Snifer,
Do you want to get the partial results from the same month last year or
you need to subtract previous month amount from YTD or MTD.
Could please explain little more with two months data ?
- AnonymousNot applicable
2017 10 75000 2017 10 35000 2017 11 95000 2017 11 20000 2017 12 100000 2017 12 5000 2018 1 2000 2018 1 2000 2018 2 3000 2018 2 1000 in the line we have for example
11/2017 ->95000-75000=20000
12/2017 -> 100000-95000=5000
1/2018 -> 2000
2/2018-> 3000-2000=1000
- v-danhe-msftMicrosoft Employee
Hi Anonymous,
Based on my test, you could refer to below calculated column:
Column = var a='Table1'[month]-1 return -(CALCULATE(SUM(Table1[amount]),FILTER('Table1','Table1'[month]=a&&'Table1'[year]=EARLIER(Table1[year])))-[amount])Result:
You could also download the pbix file to have a view.
Regards,
Daniel He
- AnonymousNot applicable
i miss to describe something important,
the month is more than time repeted since is reffered to mukltiple account code
so i need to make specific for each "code"
year month amount code year month amount code 2017 1 1000 101 2017 1 1000 101 2017 2 3000 101 2017 2 2000 101 2017 3 7000 101 wanted result-> 2017 3 4000 101 2017 4 10000 101 2017 4 3000 101 2017 5 14000 101 2017 5 4000 101 2017 6 18000 101 2017 6 4000 101 2017 7 25000 101 2017 7 7000 101 2017 8 30000 101 2017 8 5000 101 2017 9 40000 101 2017 9 10000 101 2017 10 75000 101 2017 10 35000 101 2017 11 95000 101 2017 11 20000 101 2017 12 100000 101 2017 12 5000 101 2018 1 2000 101 2018 1 2000 101 2018 2 3000 101 2018 2 1000 101 2018 3 5000 101 2018 3 2000 101 2018 4 7000 101 2018 4 2000 101 2018 5 10000 101 2018 5 3000 101 2018 6 12000 101 2018 6 2000 101 2018 7 15000 101 2018 7 5000 101 2018 8 19000 101 2018 8 4000 101 2018 9 30000 101 2018 9 11000 101 2018 10 40000 101 2018 10 10000 101 2018 11 45000 101 2018 11 5000 101 2018 12 50000 101 2018 12 5000 101 2017 1 1000 102 2017 1 1000 102 2017 2 3000 102 2017 2 2000 102 2017 3 7000 102 wanted result-> 2017 3 4000 102 2017 4 10000 102 2017 4 3000 102 2017 5 14000 102 2017 5 4000 102 2017 6 18000 102 2017 6 4000 102 2017 7 25000 102 2017 7 7000 102 2017 8 30000 102 2017 8 5000 102 2017 9 40000 102 2017 9 10000 102 2017 10 75000 102 2017 10 35000 102 2017 11 95000 102 2017 11 20000 102 2017 12 100000 102 2017 12 5000 102 2018 1 2000 102 2018 1 2000 102 2018 2 3000 102 2018 2 1000 102 2018 3 5000 102 2018 3 2000 102 2018 4 7000 102 2018 4 2000 102 2018 5 10000 102 2018 5 3000 102 2018 6 12000 102 2018 6 2000 102 2018 7 15000 102 2018 7 5000 102 2018 8 19000 102 2018 8 4000 102 2018 9 30000 102 2018 9 11000 102 2018 10 40000 102 2018 10 10000 102 2018 11 45000 102 2018 11 5000 102 2018 12 50000 102 2018 12 5000 102 - v-danhe-msftMicrosoft Employee
Hi Anonymous,
You could modify my former formula as below:
Column = var a='Table1'[month]-1 return [amount]-CALCULATE(SUM(Table1[amount]),FILTER('Table1','Table1'[month]=a&&'Table1'[year]=EARLIER(Table1[year])&&'Table1'[code]=EARLIER(Table1[code])))Result:
Regards,
Daniel He