Forum Discussion

Lena85's avatar
Lena85
Helper I
4 years ago

DATESMTD model does not work on generic date table

Hello,

 

My model has 4 tables:

1.Table with business volume over time (reporting volume_over_time)

2. Generic date table (created on the dwh level called dwh dim_calendar_dates)  

3. DAX generated table with a calendar function

CALENDAR = CALENDAR(MIN('reporting volume_over_time'[waybill_created_date_ams]),MAX('reporting volume_over_time'[waybill_created_date_ams]))  

4. Date for date periods with the following DAX:

 

Date Perriods =
UNION(
ADDCOLUMNS(
DATESMTD('CALENDAR'[Date]),
"Type", "MTD","Order",1
),
ADDCOLUMNS(
DATESQTD('CALENDAR'[Date]),
"Type", "QTD", "Order",2
),
ADDCOLUMNS(
DATESYTD('CALENDAR'[Date]),
"Type", "YTD", "Order",3
),
ADDCOLUMNS(
PREVIOUSYEAR(DATESYTD('CALENDAR'[Date])),
"Type", "Last Year", "Order",6
),
ADDCOLUMNS(
PREVIOUSQUARTER(DATESQTD('CALENDAR'[Date])),
"Type", "Last Quater", "Order",5
),
ADDCOLUMNS(
PREVIOUSMONTH(DATESMTD('CALENDAR'[Date])),
"Type", "Last Month", "Order",4
)
)

 

The idea is to create custom period slicer for the volume, so that the end user can filter volume on ''Previous month/ Year/Quarter, current MTD, QTD, YTD, all with the use of one filter. Similar solution is shown here: https://www.youtube.com/watch?v=fKygF7VEJnQ 

 

This Period filter works well ONLY when it is based on the date column from table Calendar which references a date from the Reporting volume table : 

CALENDAR = CALENDAR(MIN('reporting volume_over_time'[waybill_created_date_ams]),MAX('reporting volume_over_time'[waybill_created_date_ams])) 

 

However, I need this Date Period types to work on our dwh dim_calendar_dates generic date table, since the reporting volume weight has a multiple date references. Whenever I try to change the Calendar to be based on the dwh dim_calendar_dates, instead of reporting_volumes: 

CALENDAR = CALENDAR(MIN('dwh dim_calendar_dates'[date_id]),MAX('dwh dim_calendar_dates'[date_id])) 
then the Date in the Date Perriods table has only years 2023 and 2024, and somehow the type referencing last year's periods is connected to those future dates:
 

and none of the period types output any data:

Could anyone help me see where the issue is and how to fix it?

Thank you very much!

 

 

3 Replies