Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi guys,
I need some help in a very simplified matter.
I have this table:
All I want is the latest price of the product last year (15.12.2021 - 230 EUR).
I tried this code and got 290 EUR, which is correct, because I didn't tell him to calculate the last year:
Last Price =
VAR MaxDate = CALCULATE(MAX('Umsätze Produkt'[Datum]), ALL('Umsätze Produkt'))
RETURN
CALCULATE(SUM('Umsätze Produkt'[Preis]), FILTER('Umsätze Produkt', 'Umsätze Produkt'[Datum] = MaxDate))
I found the function "previosyear" but when I tried it, I got a blank result... :S
Last Price =
VAR MaxDate = CALCULATE(MAX('Umsätze Produkt'[Datum]), PREVIOUSYEAR('Umsätze Produkt'[Datum]))
RETURN
CALCULATE(SUM('Umsätze Produkt'[Preis]), FILTER('Umsätze Produkt', 'Umsätze Produkt'[Datum] = MaxDate))
EDIT: I forgot to mention that in my real model are a lot more different products.
Can anybody please help me?
Thank you guys
Solved! Go to Solution.
Hi @LayneCobain ,
Please try below DAX formula:
Measure =
VAR cur_date =
SELECTEDVALUE ( 'Table'[Date] )
VAR cur_year =
YEAR ( cur_date )
VAR tmp =
FILTER ( ALL ( 'Table' ), YEAR ( 'Table'[Date] ) = cur_year - 1 )
VAR last_year_latest_date =
CALCULATE ( MAX ( 'Table'[Date] ), tmp )
RETURN
CALCULATE ( MAX ( 'Table'[Price] ), 'Table'[Date] = last_year_latest_date )
Please refer the attached .pbix file
Best regards,
Community Support Team_ Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @LayneCobain ,
Please try below DAX formula:
Measure =
VAR cur_date =
SELECTEDVALUE ( 'Table'[Date] )
VAR cur_year =
YEAR ( cur_date )
VAR tmp =
FILTER ( ALL ( 'Table' ), YEAR ( 'Table'[Date] ) = cur_year - 1 )
VAR last_year_latest_date =
CALCULATE ( MAX ( 'Table'[Date] ), tmp )
RETURN
CALCULATE ( MAX ( 'Table'[Price] ), 'Table'[Date] = last_year_latest_date )
Please refer the attached .pbix file
Best regards,
Community Support Team_ Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@LayneCobain , You should use a date table for time intelligence
CALCULATE(lastnonblankvalue('Umsätze Produkt'[Datum], SUM('Umsätze Produkt'[Preis])), PREVIOUSYEAR('DAte'[DAte]))
Why Time Intelligence Fails - Powerbi 5 Savior Steps for TI :https://youtu.be/OBf0rjpp5Hw
https://amitchandak.medium.com/power-bi-5-key-points-to-make-time-intelligence-successful-bd52912a5b...
To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.
Hello amitchandak,
thank you for you help.
I added a date table and tried your code (test 2). The values are okay but in further calculations the results are "endless". I tried a code (test 1) too but it doesn't work either.
I added some more products and categories so simulate the original data model a little more and uploaded the file here.
The "end-result" should be the difference in percentage between the latest price of the previous year to the highest prices per month in the current year per category (materials).
I really don't know how to do it.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
112 | |
100 | |
77 | |
74 | |
49 |
User | Count |
---|---|
146 | |
108 | |
106 | |
90 | |
62 |