Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowThe Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.
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
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.
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.
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
Hi,
Can you show us the Table Schema. Also, Is Datum the Date Table?
Datum is indeed the date table.
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 🙂
Thank you for your reply. Still no success unfortunately, both the formulas don't seem to work properly.
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.
Hi,
Can you share this PBIX
Unfortunately, due to company policy and sensitive data, I cannot and am not allowed to externally share the file.
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 🙂
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the February 2025 Power BI update to learn about new features.
User | Count |
---|---|
86 | |
81 | |
53 | |
37 | |
37 |