Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Hi,
I want to create a KPI in my report that takes the max date from my Sales table and then compares the current year-to-date with the year-to-date of the same period previous year.
So, if we are now living on 2024-04-24, I would like to have the values:
- YTD 2024-01-01 up until 2024-04-24
- YTD previous year 2023-01-01 up until 2023-04-24
For YTD I created this, which works
Solved! Go to Solution.
@PowerRon this is the measure, it is well explained in my videos:
PYTD Sales =
VAR __Date = MAX ( 'Sales'[OrderDate] )
VAR __LastYear= YEAR ( __Date ) - 1
VAR __PDate = IF ( __LastYear <> - 1, DATE ( __LastYear, MONTH ( __Date ), DAY ( __Date ) ) )
RETURN
TOTALYTD ( [Base Sum Sales], CALCULATETABLE ( VALUES ( 'Calendar'[Date] ), 'Calendar'[Date] <= __PDate ) )
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Thnx Parvinder, yours also works.
Always glad you give me the push in the right direction
@PowerRon this is the measure, it is well explained in my videos:
PYTD Sales =
VAR __Date = MAX ( 'Sales'[OrderDate] )
VAR __LastYear= YEAR ( __Date ) - 1
VAR __PDate = IF ( __LastYear <> - 1, DATE ( __LastYear, MONTH ( __Date ), DAY ( __Date ) ) )
RETURN
TOTALYTD ( [Base Sum Sales], CALCULATETABLE ( VALUES ( 'Calendar'[Date] ), 'Calendar'[Date] <= __PDate ) )
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Hi @parry2k I have a date dimension and it is marked as a date table. Bit still couldn't get it working.
Looks like this works
As a best practice, add a date dimension in your model and use it for time intelligence calculations. Once the date dimension is added, mark it as a date table on table tools. Check the related videos on my YT channel
Add Date Dimension
Importance of Date Dimension
Mark date dimension as a date table - why and how?
Time Intelligence Playlist
Check this video and the same logic can be used for the previous year:
Learn how to compare MTD sales as of date with same number of days last year - Part 7 (youtube.com)
Power BI Time Intelligence: Compare MTD With Same Period In Previous Months - Part 6 - YouTube
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
User | Count |
---|---|
57 | |
22 | |
18 | |
16 | |
11 |
User | Count |
---|---|
85 | |
54 | |
39 | |
21 | |
18 |