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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

Cannot create measures on a date column in Analysis Services Model and in Power BI Desktop

Hello community members,

 

I am hoping you could provide some insight in what I am trying to achieve in both the AS model and in PBI Desktop.

 

Apart from the dates table I have created in the AS model, there are of course more tables in the model that have date columns, such as Purchase Order Creation Date, Purchase Order Update Date etc. If I want to create a measure on these columns, for example a simple DATEDIFF, the DAX formula editor will not let me select the right column. It seems that it only comes up with suggestions for other (already created) measures, which are completely unrelated to the table/column I want to create it on. For example, it is giving suggestions to do the DATEDIFF on a Count Amount column... If I type in the table and column name myself, it gives that squigly line telling me that it can't find that name. 

 

This is happening both in the model as well as the report level measures and I can't find the reason for the life of me. 

 

Can anyone help me out?

 

Thanks in advance, 

 

Thomas

2 ACCEPTED SOLUTIONS
parry2k
Super User
Super User

@Anonymous if you adding a measure, you cannot directly use the column, you have to use some sort of aggregation, so you can say DATEDIFF ( MAX ( Table[Date] ), MAX ( Table[Date2] ), MONTH )

 

so MAX will be used as aggregation, now not sure if you want to add this as a measure? Maybe you want to add this datediff as a column but that is a separate point.

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

v-eachen-msft
Community Support
Community Support

Hi @Anonymous ,

 

The parameters in measure cannot be columns directly. You could refer to the following DAX:

Measure =
DATEDIFF (
    SELECTEDVALUE ( 'Table'[Start Date] ),
    SELECTEDVALUE ( 'Table'[End Date] ),
    DAY
)

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Thanks a lot for the quick replies! 

v-eachen-msft
Community Support
Community Support

Hi @Anonymous ,

 

The parameters in measure cannot be columns directly. You could refer to the following DAX:

Measure =
DATEDIFF (
    SELECTEDVALUE ( 'Table'[Start Date] ),
    SELECTEDVALUE ( 'Table'[End Date] ),
    DAY
)

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.
parry2k
Super User
Super User

@Anonymous if you adding a measure, you cannot directly use the column, you have to use some sort of aggregation, so you can say DATEDIFF ( MAX ( Table[Date] ), MAX ( Table[Date2] ), MONTH )

 

so MAX will be used as aggregation, now not sure if you want to add this as a measure? Maybe you want to add this datediff as a column but that is a separate point.

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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