Forum Discussion
calculating difference
Hi,
I am stucked with the following question.
| Product Code | Sales | Date |
| A | 10 | 01/02/2022 |
| B | 10 | 01/02/2022 |
| C | 10 | 01/02/2022 |
| D | 10 | 01/02/2022 |
| A | 10 | 01/03/2022 |
| A | 10 | 01/03/2022 |
| B | 10 | 01/03/2022 |
| C | 10 | 01/03/2022 |
| A | 10 | 01/04/2022 |
| B | 10 | 01/04/2022 |
I would look for a equation that can calculate the difference between two period of time. In this data set every month I will update the sales record and I need a measure that can gives me somthing like below:
Assume today is Apr:
| Product Code | Total Sales | Difference vs Last month |
| A | 40 | 10 |
| B | 30 | 10 |
| C | 20 | 0 |
| D | 10 | 0 |
What I need is the measure that can complete "Difference vs Last month" at the same time it does not require filter on visualization.
I can do this by using two spreadsheet inside powerBI, however, I hope this can be on 1 spreadsheet so everytime I dont have to refresh two file.
Is there any way to do this?
Thank you!
- Anonymous3 years ago
Hi,
I am not sure what's wrong with my equation as it keep return error message.
MoM Revenue Growth =VAR _Actual =sum('Table'[Sales])VAR _PrevMonth =CALCULATE(CALCULATE(sum('Table'[Sales])),PREVIOUSMONTH ('Table'[Date]))RETURN_Actual - _ PrevMonthDo you know what I did wrong?Thanks!
9 Replies
- NyeinChanRegular Visitor
You can use either time intelligence build in function or just create common dimension column (i.e. month for you) and create a measure calculating sale difference based on current vs previous period.
- PabloDehezaSolution Sage
Hey there!
Try this:
MoM Revenue Growth = VAR _Actual = Total VAR _PrevMonth = CALCULATE( Total, PREVIOUSMONTH( YourDateColumn ) ) RETURN _Actual - _ PrevMonthLet me know if that helps!
- AnonymousNot applicable
Hi,
I am not sure what's wrong with my equation as it keep return error message.
MoM Revenue Growth =VAR _Actual =sum('Table'[Sales])VAR _PrevMonth =CALCULATE(CALCULATE(sum('Table'[Sales])),PREVIOUSMONTH ('Table'[Date]))RETURN_Actual - _ PrevMonthDo you know what I did wrong?Thanks!- PabloDehezaSolution Sage
Can you please provide the error message you are getting? Thanks
- tamerj1Community Champion
Hi Anonymous
What is the difference?