Forum Discussion

EndriuBlack's avatar
EndriuBlack
Frequent Visitor
3 years ago
Solved

Datediff function doesn't "see" datas from fact table

Hello,

I'm using Power Bi Desktop Report Server version from may 2022.

 

I'm trying to use DATEDIFF function to calculate days between two dates. Unfortunately when I want to use as argument a date from a data table I can only see measures. I was trying to add a calculated column in fact tabel and all went well. The "datediff" function acted correctly but I see I cannot use this solution in my report becouse refreshing data lasts too long. So I need to create a measure but I don't know where is a problem.

 

 

 

If somebody has an idea what can be wrong in my model I would be very grateful for help 🙂

 

Best regards,

Andrew

 

 

  • Hi, EndriuBlack ,
    For measures, there's not row context. So you cannot use directly the columns, you need to aggreagate your data so some aggregation fucntion such as MAX. IF you wrap it to MAX, then you can use the column.
    Since measures are calculated only based on current filter context, you don't have access to rows context.

    You can also use X function to retrieve that row context and access the rows (MAXX).

     

2 Replies

  • Hi, EndriuBlack ,
    For measures, there's not row context. So you cannot use directly the columns, you need to aggreagate your data so some aggregation fucntion such as MAX. IF you wrap it to MAX, then you can use the column.
    Since measures are calculated only based on current filter context, you don't have access to rows context.

    You can also use X function to retrieve that row context and access the rows (MAXX).

     
    • EndriuBlack's avatar
      EndriuBlack
      Frequent Visitor

      Thank You !

      Now I understand it. I have used MAX function for both dates and the measure works. I see that calculating last very long so I cannot use this parameter in my report but now I know more for the future 😉

       

      Best Regards,