I’m trying to compare sales values last to date against this year to date. I have a table called Sales and a date table called Calendar. They are linked on Order Date from Sales to Date in Calendar, single from Calendar to Sales.
UNTIL I filter on any of the fields in the Sales table, which don’t have a sale exactly 365 days ago.
But I know I should be using the Calendar date field, so I tried:
LYTD Sell Value = TOTALYTD( SUM(Sales[Line Value]), DATEADD(Calendar[Date], -365, DAY))
Yet this doesn’t work at all.
Does anyone have any suggestions? Anything would be greatly appreciated.
thanks
—————————— Andy ——————————
Lorenzo Vercellati
Member
November 25, 2019 at 4:57 AM
Hi,
Total Sell Value = SUM(Sales[Line Value] YTD Sell Value= TOTALYTD([Total Sell Value], Calendar[Date]) LYTD Sell Value = CALCULATE([YTD Sell Value], SAMEPERIODLASTYEAR(Calendar[Date]))
Regards Lorenzo
—————————— Lorenzo Vercellati PowerBI Solution Architect SolidQ Milan 3382819866 —————————— ——————————————-
Vishesh Jain
Member
December 2, 2019 at 5:03 AM
Hi ,
Just a side-note for the DATEADD() function. It is tricky function and I try to avoid using it. For DATEADD() you need to have all the calendar dates that are in your calculation, in your calendar table. If your result dates do not exist in your calendar table, it will give an error.
So try avoiding it and rather just subtract? the number of days directly from the date.
However, the solution that Lorenzo provided is the best way to go.
Thank you,
—————————— Vishesh Jain Owner VR Construction —————————— ——————————————-
Andy Robinson
Member
December 3, 2019 at 3:45 AM
thank you very much. really appreciate the help
—————————— Andy Robinson —————————— ——————————————-
Please note:
This action will also remove this member from your connections and send a report to the site admin.
Please allow a few minutes for this process to complete.
Report
You have already reported this .
Welcome to our new site!
Here you will find a wealth of information created for peopleĀ that are on a mission to redefine business models with cloud techinologies, AI, automation, low code / no code applications, data, security & more to compete in the Acceleration Economy!