The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hello everyone i am struggling with a simple issue on Power BI desktop.
I created a matrix like this where both description and amount have a reference date in column (the two cells are obviously together), i need to do the differences between the two years using a new measure and where for product A i expect 30 as delta amount and 2 as delta item sold.
Thank you very much for your time!
2023 | 2023 | 2024 | 2024 | ||
PRODUCT | DESCRIPTION | AMOUNT | ITEMS SOLD | AMOUNT | ITEMS SOLD |
A | ALFA | 40 | 1 | 70 | 3 |
B | BETA | 50 | 2 | 80 | 4 |
C | GAMMA | 60 | 3 | 90 | 5 |
Solved! Go to Solution.
Please add these measures to matrix values.
Please add these measures to matrix values.
Thank you, it works.
Last question: how do I modify the code if i will have consecutive dates during the year?
Let me explain, if the data will become more frequent with 3/4 monthly observations not yearly?
Thank you
Please try this
Step3 : Create this measure. And use Year from calendar table in your matrix.
Do you need a new pbix file?
First check the solution which I just shared and if it doesn''t work or I did not understand your requirement, please share pbix file.
Can you shed some more light on this.. Will the years be dynamic? Also if you could share a sample PBIX file it would help to figure out a solution.
Hi, @NewPowerUser198
Based on the PBIX file you provided, you can calculate Amount between two years and Id_client between two years through DAX below.
DAX formula:
Amount between two years =
var _Year=YEAR(CALCULATE(MIN('Foglio1'[date])))
VAR _a = CALCULATE(SUM(Foglio1[amount]),FILTER('Foglio1',YEAR('Foglio1'[date])=_Year&&'Foglio1'[product]='Foglio1'[product]))
VAR _b = CALCULATE(SUM('Foglio1'[amount]),FILTER('Foglio1',YEAR('Foglio1'[date]) =_Year+1&&'Foglio1'[product]='Foglio1'[product]))
RETURN _b -_a
Id_client between two years =
var _Year=YEAR(CALCULATE(MIN('Foglio1'[date])))
VAR _a = CALCULATE(COUNTROWS('Foglio1'),FILTER('Foglio1',YEAR('Foglio1'[date])=_Year&&'Foglio1'[product]='Foglio1'[product]))
VAR _b = CALCULATE(COUNTROWS('Foglio1'),FILTER('Foglio1',YEAR('Foglio1'[date]) =_Year+1&&'Foglio1'[product]='Foglio1'[product]))
RETURN _b -_a
Use Table visual to reflect the results:
I have provided the PBIX file used this time below. I hope this helps. Let me know if you have any further questions.
How to Get Your Question Answered Quickly
If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .
Best Regards
Jianpeng Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thank you for your time and your help, i need to show the result on the same table i provided. If I understood well this works with a new table, is it correct?
User | Count |
---|---|
16 | |
8 | |
6 | |
6 | |
5 |
User | Count |
---|---|
23 | |
13 | |
13 | |
8 | |
8 |