Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
sandip
Helper III
Helper III

Why my calendar function is not working ? Please help

Hi,

I am using the below DAX code:

Date Table =
var TBL_Date =
SELECTCOLUMNS(
FILTER(
ADDCOLUMNS(
'Parent Task SLA',
"Start Time", 'Parent Task SLA'[start_time],
"End Time", 'Parent Task SLA'[end_time]
),
[End Time] <> BLANK()
),
"Start Time",[Start Time],
"End Time", [End Time]
)
var TBL_Calendar = CALENDAR(TBL_Date[Start Time],TBL_Date[End Time])
return TBL_Calendar
 
but below error message is showing:
Cannot find table 'TBL_Date' or cannot find column Start Time
 
Please help me?
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@sandip , try like

CALENDAR(minx(TBL_Date,TBL_Date[Start Time]),maxx(TBL_Date,TBL_Date[End Time]))

or

CALENDAR(minx(TBL_Date,[Start Time]),maxx(TBL_Date,[End Time]))

View solution in original post

3 REPLIES 3
v-xuding-msft
Community Support
Community Support

Hi @sandip ,

 

The range of dates is from the specified start date to the specified end date, inclusive of those two dates. You write two columns in the calendar function rather than two dates.

CALENDAR 

 

The formulas that @amitchandak suggests should work perfectly. Or you could just write like this:

TBL_Calendar =
CALENDAR ( MIN ( TBL_Date[Start Time] ), MAX ( TBL_Date[End Time] ) )

 

 Creating Calendar Table in Power BI using DAX Functions 

 

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
amitchandak
Super User
Super User

@sandip , try like

CALENDAR(minx(TBL_Date,TBL_Date[Start Time]),maxx(TBL_Date,TBL_Date[End Time]))

or

CALENDAR(minx(TBL_Date,[Start Time]),maxx(TBL_Date,[End Time]))

Hi,

Actually your second expression works well for me like below:

Date Table =
var TBL_Date =
SELECTCOLUMNS(
FILTER(
ADDCOLUMNS(
'Task SLA',
"Start Time", 'Task SLA'[start_time],
"End Time", 'Task SLA'[end_time]
),
[End Time] <> BLANK()
),
"Start Time",[Start Time],
"End Time", [End Time]
)
var TBL_Calendar = CALENDAR(minx(TBL_Date,[Start Time]),maxx(TBL_Date,[End Time]))
return
TBL_Calendar

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.