The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi,
I have a matrix table showing data for each month.
Can you please advise what is the formula to calculate difference between last month vs first month.
For example: 14-49 = -35
Thank you in advance!
Solved! Go to Solution.
Hi @wy_khoo ,
According to your description, here are my steps you can follow as a solution.
(1) This is my test data.
(2) We can create a measure.
Measure =
var _first_date=CALCULATE(MIN('Table'[date]),ALLSELECTED('Table'))
var _first_value=CALCULATE(SUM('Table'[value]),FILTER(ALLSELECTED('Table'),MONTH('Table'[date])=MONTH(_first_date) && YEAR('Table'[date])=YEAR(_first_date)))
var _value=CALCULATE(SUM('Table'[value]),FILTER(ALLSELECTED('Table'),YEAR('Table'[date])=YEAR(MAX('Table'[date])) && MONTH('Table'[date])=MONTH(MAX('Table'[date]))))
RETURN _value-_first_value
(3) Then the result is as follows.
If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @wy_khoo ,
According to your description, here are my steps you can follow as a solution.
(1) This is my test data.
(2) We can create a measure.
Measure =
var _first_date=CALCULATE(MIN('Table'[date]),ALLSELECTED('Table'))
var _first_value=CALCULATE(SUM('Table'[value]),FILTER(ALLSELECTED('Table'),MONTH('Table'[date])=MONTH(_first_date) && YEAR('Table'[date])=YEAR(_first_date)))
var _value=CALCULATE(SUM('Table'[value]),FILTER(ALLSELECTED('Table'),YEAR('Table'[date])=YEAR(MAX('Table'[date])) && MONTH('Table'[date])=MONTH(MAX('Table'[date]))))
RETURN _value-_first_value
(3) Then the result is as follows.
If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous , thank you for your solution. It works!
Hi @wy_khoo
Please refer to the linked tutorial:
https://www.youtube.com/watch?v=cAxoxvnN_vQ
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly
User | Count |
---|---|
77 | |
75 | |
36 | |
31 | |
29 |
User | Count |
---|---|
94 | |
80 | |
55 | |
48 | |
48 |