Forum Discussion
problem with slicer and dynamic dates
You can also use the Parallelperiod i thunk this is the formula name (not near computer) to have last year same timeframe look it up in the forum or google it for a full detail of how it runs.
Once again sorry for sligth detail but i'm on my cellphone.
Mfelix
You mean as 4th parameter of TOTALYTD function? I've tried a second ago but I obtain silly numbers. I've used on the current year expecting a total just a bit less (cause it should not count future payments instead it returns only a fraction of what it should).
- MFelix9 years agoSuper UserI don't know how you set up your model and dates but the Totalytd gives the values from 1 jan to date selected on slicer when you place the previous year in the formula start and end date ut should give you the previoud year value.
Again not on my computer cannot show with measures.
Mfelix - MFelix9 years agoSuper User
Hi acco,
Just did a siomple file with dates starting from 01/01/2016 until 31/12/2019 and added a value for each year I add 1 so all dates in 2016 are 1, 2017 are 2, 2018 are 3, so forth. Then I added this two measures:
YTD = TOTALYTD(SUM(Table1[Value]);Table1[Date]) YTDPY = TOTALYTD(SUM(Table1[Value]);DATEADD(Table1[Date];-1;YEAR))
This gives me the total of value for each year based on the filters I have, so if you count the days between 01/01 and 22/03 you have for 2016 - 82 days and for 2017 - 81 so taking into account that the value double we have a result of 82 for PY and 162 for Current Year as you can see in the print below, please adapt the formulas above to your requisitions.
Regards,
Mfelix
- acco9 years agoFrequent Visitor
Thanks for your answer and your time.
To clear my situation I've created an example:
I've recreated a simple set of my data, with the 3 columns involved in this calculation.
All my charts are designed on "DataEndCover" (red box). In the example I use the TOTALYTD function and I obtain a quite precise result (140 euro), quite because analizing the last date about "PaymentDay" (small green box), that is 22nd march 2017, there are 2 items paid (small purple box) which have subsequent date.
So when I create the TOTALYTD for LastYear the result is wrong because it will consider all the item between 1st january 2016 and 11 june 2016 (big purple box) BUT the real range should be from 1st january 2016 to 22 march 2016 (big green box).To have the most correct data I should limit, in current year and in last year, all items that have "EndDayCover" from 1st january to 22 march.
There is a way to get it?- MFelix9 years agoSuper User
Hi acco,
I think something is missing in my perception of your problem because I have made a sample with the date you show and if I do the following measures they return the correct result, however my slicer are made based on PaymentDay, should they be based on CoverEndDay?
YTD = TOTALYTD(SUM(Table1[Income]);Table1[PaymentDay]) YTD-LY = TOTALYTD(SUM(Table1[Income]);DATEADD(Table1[PaymentDay];-1;YEAR))
Can you plewase prepare a PBIX with the data and slicers that you want so that I can check if I'm not calculating everything as you need.
Regards
Mfelix