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
kkanda
Resolver I
Resolver I

Unable to generate a calendar table from a date measure

Hi,

I have a set of dates from Date table (the usual Dim_Date) in a slicer. When I select a single date from the slicer, I want to create a calendar table with start date of 7 days before the selected date and an end date of 7 days after the selected date. Depending on my selection in the slicer the Date column will have varying dates for 15 days. If there is no selection i.e. the slicer has a selection of more than one value, the calendar table will not have any values. I want to use this column of dates as the X axis of a chart to plot variables in the Y axis. I am using the following DAX:

selDate = SELECTEDVALUE(Table[Date],UNICHAR(32))... 

The new table is named as selTable - 

selTable = CALENDAR(selDate-7, selDate + 7)
I selected the ShortDate format for selDate. When I display the values in a card, the value shows correctly and so are the dates with selDate+7 or selDate-7. 

But the selTable is giving me an error "MdxScript(Model) Cannot convert " of type Text to Date". The measure selDate is already having a Date format. I am at a loss what to do. Please advise where I am going wrong.
Thanks in advance

 

 

1 ACCEPTED SOLUTION

You cannot create a table from a measure.

 

You can create a virtual table variable as part of your measure computation, but the final result of a measure needs to be a scalar (a single value).

View solution in original post

3 REPLIES 3
kkanda
Resolver I
Resolver I

Hello lbendlin, Thanks for the reply. I want to create a single column table only with dates. For example, with a code of  

SelTable = CALENDAR(DATE(2024,1,1), DATE(2024,2,1))
will create a single column table with dates listed from 1st Jan to 1st Feb 2024. I want to know whether it can be achieved by a measure

You cannot create a table from a measure.

 

You can create a virtual table variable as part of your measure computation, but the final result of a measure needs to be a scalar (a single value).

lbendlin
Super User
Super User

Creating calculated columns from measures is futile. Creating calculated tables from measures is impossible* as measures return a scalar value (* unless you were going for a single row/single column table)

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.