Forum Discussion
Last period Data based on Date/Quarter/Month/Week Filter selection
- 8 years ago
Its all about filter context, Try creating a lookupdate table with Just YEARMONTHSHORT values
YEARMONTHS = VALUES(date[YearMonthShort])
Relate that to your data table and set your slice on that.
If doesn't work, you could try NOT using a SLICER to select the month but instead use a disconnected slicer to have user select month, date or whatever and then use that SELECTEDVALUE of what the user selectes as teh desired period in your measures.
Also if you want to sort your months use the sortby column from the modeling tab in the table view and sort the Month name by Month Index. As good date table is essential there are many articles on this if you search but here is some DAX to create one dynamically if you don't have a good one already built. It also includes examples of some custom date fields my company uses based on our Fiscal Years (starts 4/1/1962)
Hi Seward12533,
Thanks you so much for your reply. I got the logic now. I follow all the steps which you mentioned.
1) Created Calendar Table. (Used your Calendar script only)
2) Changed the calculated field as follows: (For testing purpose calculating last 3 days value)
OIF_Value_EUR_Calc = VAR LastDt = MAX (V_OPPORTUNITIES[Created_Date]) RETURN
CALCULATE (
SUM ( V_OPPORTUNITIES_OIF[OIF_Value_EUR] ),DateDIM,
FILTER(ALL(DateDIM[Date]) , DateDIM[Date]<=LastDt&&DateDIM[Date]>=LastDt-3))
But when I select MonthYear as 'Feb2-2018', The calculated filed not showing me last 3 months value.
'OIF_Value_EUR' and 'OIF_Value_EUR_Calc' showing me same value. Am I missing anything? Could you please help?