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
Anonymous
Not applicable

Comparing this year YTD vs last year YTD

Hello helpful community!

 

I am struggeling with comparing the total sales of two years, YTD 2019 vs YTD 2018. My total sales measure seams to be completely fine, however, I can not get the data to show ytd 2019 compared to the same ytd 2018 period. I have tried almost every video suggestion on youtube and every post here in the forum, but without success.

 

In the pics below I have used the 'sameperiodlastyear' function. Anyone who can help me out?

 

Ps. 'totale omzet' = total sales, I adjusted the header in the table.

 

Kind regards,

 

Bas 

1.png2.PNG

 

 

12 REPLIES 12

Hi there, 
I am using Sample Adventure Works data. Pls try using this measure & check the relationship between fact table & date table.

Let me know if this solves your query.
2019-09-27 (2).png2019-09-27 (3).png

Anonymous
Not applicable

 

Thank you for your reply

 

The formula seems to be working fine and the dates seem to have the correct relationship (Datuminvoiced & Datum ISO). But when I put the formula into the table, it displays the warning: "cant't display the visual". Total sales is defined as: "sum(DATAINPUT_POWERBI_1_2019[omzet]) just like in th formula: "totalsalesPYYTD". On itself, it sums the revenue perfectly but when couples with the new measure it doesn't work for some reason.

 

1.png2.PNG

Do you have continuous dates. In case some dates are missing sameperiodlastyear might not work fine

In such case you to have try formula like

On the Fly Change % = 
Var _last_year= (max('Date'[Date Filer]))-365
Var   _This_year=year(max('Date'[Date Filer]))
Var _min_last_year= (maxx('Date',STARTOFYEAR(DATEADD('Date'[Date Filer],-12,MONTH))))
Var   _min_This_year=year(max(STARTOFYEAR('Date'[Date Filer])))

Var _last_year_val= CALCULATE(sum(Sales[Sales Amount]),(Sales[Sales Date])<=_last_year && (Sales[Sales Date]) >=_min_last_year)
Var   _This_year_val =CALCULATE(sum(Sales[Sales Amount]),(Sales[Sales Date])<=_This_year && (Sales[Sales Date]) >=_min_This_year)
return
(_This_year_val-_last_year_val)/_last_year_val*100

Hi,
Can you pls try creating the relationship between those two columns using date column (of datatype date) instead of datekey column.

Thanks

Anonymous
Not applicable

Hi,

 

Can you show us the Table Schema. Also, Is Datum the Date Table?

Anonymous
Not applicable

Datum is indeed the date table.

 

3.png

Anonymous
Not applicable

Hi,

 

Instead of SAMEPERIODLASTYEAR(), Can you try using  DATEADD(Date[Date],-1,Year)

Best Regards,
Vignesh M

If what I suggested worked for you feel free to Drop a "Kudos" and Consider to "Accept as Solution" if I solved your Issue 🙂

Anonymous
Not applicable

Thank you for your reply. Still no success unfortunately, both the formulas don't seem to work properly. 

 

5.PNG6.PNG

Anonymous
Not applicable

Okay just realized the bracket issue and I got the formula to work but the table doens't display the values I'd like to see.7.PNG

Anonymous
Not applicable

Hi,

 

Can you share this PBIX

Anonymous
Not applicable

Unfortunately, due to company policy and sensitive data, I cannot and am not allowed to externally share the file.

Anonymous
Not applicable

Hi,

 

There is a Bracket issue. Include another Simple Bracket at the End

 

Best Regards,
Vignesh M

If what I suggested worked for you feel free to Drop a "Kudos" and Consider to "Accept as Solution" if I solved your Issue 🙂

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.