Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
Jonjon_99
Helper I
Helper I

KPI YTD vs SAME MONTH LAST YEAR

hi, i am trying to create KPI that will display percentage of difference between YTD data vs same month last year.
anyone can help me find solution for this?

i want to see the percentage of Jan - June 2022  vs Jan - June 2023 total units in my KPI card. (365,317 vs 362,110)

Jonjon_99_0-1692688095986.png

this is my DAX for YTD Units

YTD Units = CALCULATE([Units],DATESYTD('Date'[Date]))
and YoY difference
YoY Units Diff = IF(ISBLANK([Total Units LY]),BLANK(),[Units]-[Total Units LY])

when i use KPI card the result is not correct. 
Jonjon_99_1-1692688434106.png

i also tried units lastyear DAX but it calculates the subtotal of last year (848,424) instead of last years Jan-June data. (365,317)

Total Units LY = CALCULATE([Units],  SAMEPERIODLASTYEAR('Date'[Date]))
Jonjon_99_2-1692688610144.png

 

can anyone help me fix this issue? i would like to see goal = 365,317 (Jan to June 2022 total units)

thanks! 🙂

@johnyip  😄

1 ACCEPTED SOLUTION

@Jonjon_99 

Please create a new measure as below, and then use it in your KPI Visual.

Total Units LY = 
VAR CurrentDate= VALUE(FORMAT(MAXX(ALLSELECTED('financials (2)'),'financials (2)'[Date]),"YYYYMMDD"))
VAR TargetYear = ROUNDDOWN(CurrentDate/10000,0)-1
VAR TargetMonth = ROUNDDOWN((CurrentDate/10000 - TargetYear-1)*100,0)
VAR TargetDay = ((CurrentDate/10000 - TargetYear-1)*100-TargetMonth)*100
VAR TargetDate = DATE(TargetYear,TargetMonth,TargetDay)
RETURN 
CALCULATE([Units], 'Date'[Date]<= TargetDate && 'Date'[Year] = TargetYear)


Please mark my post as the solution if this answers your question!
Appreciate your Kudos !!

View solution in original post

4 REPLIES 4
johnyip
Super User
Super User

Please provide your sample pibx.



Please mark my post as the solution if this answers your question!
Appreciate your Kudos !!

@Jonjon_99 

Please create a new measure as below, and then use it in your KPI Visual.

Total Units LY = 
VAR CurrentDate= VALUE(FORMAT(MAXX(ALLSELECTED('financials (2)'),'financials (2)'[Date]),"YYYYMMDD"))
VAR TargetYear = ROUNDDOWN(CurrentDate/10000,0)-1
VAR TargetMonth = ROUNDDOWN((CurrentDate/10000 - TargetYear-1)*100,0)
VAR TargetDay = ((CurrentDate/10000 - TargetYear-1)*100-TargetMonth)*100
VAR TargetDate = DATE(TargetYear,TargetMonth,TargetDay)
RETURN 
CALCULATE([Units], 'Date'[Date]<= TargetDate && 'Date'[Year] = TargetYear)


Please mark my post as the solution if this answers your question!
Appreciate your Kudos !!

hi John. this works! thank you very much for your help, i really appreciate your time working on it!!!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.