The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi everyone !
I try to create a calendar table based on multiple columns to get the first date and the last date.
Table_1 contains the columns DATE_1, DATE_2 and DATE_3.
I find out to get the first date and the last date for one column:
CALENDAR_TABLE = CALENDAR(FIRSTDATE(TABLE_1[DATE_1]);LASTDATE(TABLE_1[DATE_1]))
But I need to refer to the 3 columns, not only the DATE_1 table !
If I understand, I need to:
Someone could help me on that ?
Regards,
CR
Solved! Go to Solution.
Hi @CR ,
why so complicated?
Calendar_auto = CALENDARAUTO()
Or try this...
CALENDAR_TABLE =
VAR DATE_TABLE =
UNION (
SELECTCOLUMNS ( Table_1, "Date", Table_1[DATE_1] ),
SELECTCOLUMNS ( Table_1, "Date", Table_1[DATE_2] ),
SELECTCOLUMNS ( Table_1, "Date", Table_1[DATE_3] )
)
RETURN
CALENDAR ( MINX ( DATE_TABLE, [Date] ), MAXX ( DATE_TABLE, [Date] ) )
Regards,
Marcus
Dortmund - Germany
If I answered your question, please mark my post as solution, this will also help others.
Please give Kudos for support.
Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials
Hi @CR
look at this.
CALENDARAUTO()
https://docs.microsoft.com/en-us/dax/calendarauto-function-dax
Regards,
Marcus
Dortmund - Germany
If I answered your question, please mark my post as solution, this will also help others.
Please give Kudos for support.
Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials
Hi @mwegener
Thanks for your quick answer. I also tried to generate a calendar with CALENDARAUTO function including a variable gathering my 3 columns coming from TABLE_1.
Calendar_auto =
GENERATE(
CALENDARAUTO();
VAR CurrentDay = UNION(
SELECTCOLUMNS('Table_1';"table 1";'Table_1'[DATE_1]);
SELECTCOLUMNS('Table_1';"table 2";'Table_1'[DATE_2]);
SELECTCOLUMNS('Table_1';"table 3";'Table_1'[DATE_3]))
RETURN
CurrentDay)
In some ways, it worked because it contains all the days of the years 2019 / 2020 / 2021 / 2022 / 2023.
But, all dates are duplicated several times (DD/MM/YYY):
01/01/2019 |
01/01/2019 |
01/01/2019 |
01/01/2019 |
01/01/2019 |
02/01/2019 |
02/01/2019 |
02/01/2019 |
02/01/2019 |
Do you see why ?
Regards,
CR
Hi @CR ,
why so complicated?
Calendar_auto = CALENDARAUTO()
Or try this...
CALENDAR_TABLE =
VAR DATE_TABLE =
UNION (
SELECTCOLUMNS ( Table_1, "Date", Table_1[DATE_1] ),
SELECTCOLUMNS ( Table_1, "Date", Table_1[DATE_2] ),
SELECTCOLUMNS ( Table_1, "Date", Table_1[DATE_3] )
)
RETURN
CALENDAR ( MINX ( DATE_TABLE, [Date] ), MAXX ( DATE_TABLE, [Date] ) )
Regards,
Marcus
Dortmund - Germany
If I answered your question, please mark my post as solution, this will also help others.
Please give Kudos for support.
Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast - Power BI Tutorials
Thanks Marcus, this is indeed more simple and... really efficient !
CR