Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

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...
  • parry2k's avatar
    6 years ago

    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.

  • v-eachen-msft's avatar
    6 years ago

    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
    )