Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now
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
Solved! Go to Solution.
Hi @snifer,
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
Hi @snifer,
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
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 | |||
Hi @snifer,
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
Hi @snifer,
Could you have downloaded my pbix file to have a view? All the data I used is given from your last post, if it is still incorrect, could you please upload your pbix file to OneDrive or Dropbox and send the link here to let me have a test?
Regards,
Daniel He
maybe i find out why is not working in the table are many company with same month code year so maybe addiing a condition for same compnay will fix everything .. how i can add this contition?
year | month | amount | code | company | year | month | amount | code | company | |||
2017 | 1 | 1000 | 101 | dk | 2017 | 1 | 1000 | 101 | dk | |||
2017 | 2 | 3000 | 101 | dk | 2017 | 2 | 2000 | 101 | dk | |||
2017 | 3 | 7000 | 101 | dk | wanted result-> | 2017 | 3 | 4000 | 101 | dk | ||
2017 | 4 | 10000 | 101 | dk | 2017 | 4 | 3000 | 101 | dk | |||
2017 | 5 | 14000 | 101 | dk | 2017 | 5 | 4000 | 101 | dk | |||
2017 | 6 | 18000 | 101 | dk | 2017 | 6 | 4000 | 101 | dk | |||
2017 | 7 | 25000 | 101 | dk | 2017 | 7 | 7000 | 101 | dk | |||
2017 | 8 | 30000 | 101 | dk | 2017 | 8 | 5000 | 101 | dk | |||
2017 | 9 | 40000 | 101 | dk | 2017 | 9 | 10000 | 101 | dk | |||
2017 | 10 | 75000 | 101 | dk | 2017 | 10 | 35000 | 101 | dk | |||
2017 | 11 | 95000 | 101 | dk | 2017 | 11 | 20000 | 101 | dk | |||
2017 | 12 | 100000 | 101 | dk | 2017 | 12 | 5000 | 101 | dk | |||
2018 | 1 | 2000 | 101 | dk | 2018 | 1 | 2000 | 101 | dk | |||
2018 | 2 | 3000 | 101 | dk | 2018 | 2 | 1000 | 101 | dk | |||
2018 | 3 | 5000 | 101 | dk | 2018 | 3 | 2000 | 101 | dk | |||
2018 | 4 | 7000 | 101 | dk | 2018 | 4 | 2000 | 101 | dk | |||
2018 | 5 | 10000 | 101 | dk | 2018 | 5 | 3000 | 101 | dk | |||
2018 | 6 | 12000 | 101 | dk | 2018 | 6 | 2000 | 101 | dk | |||
2018 | 7 | 15000 | 101 | dk | 2018 | 7 | 5000 | 101 | dk | |||
2018 | 8 | 19000 | 101 | dk | 2018 | 8 | 4000 | 101 | dk | |||
2018 | 9 | 30000 | 101 | dk | 2018 | 9 | 11000 | 101 | dk | |||
2018 | 10 | 40000 | 101 | dk | 2018 | 10 | 10000 | 101 | dk | |||
2018 | 11 | 45000 | 101 | dk | 2018 | 11 | 5000 | 101 | dk | |||
2018 | 12 | 50000 | 101 | dk | 2018 | 12 | 5000 | 101 | dk | |||
2017 | 1 | 1000 | 102 | dk | 2017 | 1 | 1000 | 102 | dk | |||
2017 | 2 | 3000 | 102 | dk | 2017 | 2 | 2000 | 102 | dk | |||
2017 | 3 | 7000 | 102 | dk | wanted result-> | 2017 | 3 | 4000 | 102 | dk | ||
2017 | 4 | 10000 | 102 | dk | 2017 | 4 | 3000 | 102 | dk | |||
2017 | 5 | 14000 | 102 | dk | 2017 | 5 | 4000 | 102 | dk | |||
2017 | 6 | 18000 | 102 | dk | 2017 | 6 | 4000 | 102 | dk | |||
2017 | 7 | 25000 | 102 | dk | 2017 | 7 | 7000 | 102 | dk | |||
2017 | 8 | 30000 | 102 | dk | 2017 | 8 | 5000 | 102 | dk | |||
2017 | 9 | 40000 | 102 | dk | 2017 | 9 | 10000 | 102 | dk | |||
2017 | 10 | 75000 | 102 | dk | 2017 | 10 | 35000 | 102 | dk | |||
2017 | 11 | 95000 | 102 | dk | 2017 | 11 | 20000 | 102 | dk | |||
2017 | 12 | 100000 | 102 | dk | 2017 | 12 | 5000 | 102 | dk | |||
2018 | 1 | 2000 | 102 | dk | 2018 | 1 | 2000 | 102 | dk | |||
2018 | 2 | 3000 | 102 | dk | 2018 | 2 | 1000 | 102 | dk | |||
2018 | 3 | 5000 | 102 | dk | 2018 | 3 | 2000 | 102 | dk | |||
2018 | 4 | 7000 | 102 | dk | 2018 | 4 | 2000 | 102 | dk | |||
2018 | 5 | 10000 | 102 | dk | 2018 | 5 | 3000 | 102 | dk | |||
2018 | 6 | 12000 | 102 | dk | 2018 | 6 | 2000 | 102 | dk | |||
2018 | 7 | 15000 | 102 | dk | 2018 | 7 | 5000 | 102 | dk | |||
2018 | 8 | 19000 | 102 | dk | 2018 | 8 | 4000 | 102 | dk | |||
2018 | 9 | 30000 | 102 | dk | 2018 | 9 | 11000 | 102 | dk | |||
2018 | 10 | 40000 | 102 | dk | 2018 | 10 | 10000 | 102 | dk | |||
2018 | 11 | 45000 | 102 | dk | 2018 | 11 | 5000 | 102 | dk | |||
2018 | 12 | 50000 | 102 | dk | 2018 | 12 | 5000 | 102 | dk |
Hi @snifer,
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
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 ?
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
Check out the October 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
115 | |
112 | |
105 | |
95 | |
58 |
User | Count |
---|---|
174 | |
147 | |
136 | |
102 | |
82 |