Forum Discussion
Calculating Average Days
Hi All,
I am trying to calculate the average number of days between two dates in two different tables. I've used the following formula to create a new column in one of the tables:
Hi Richard
The relationship setup seems ok.
I recreated what you have
I reworked the measure a little. I had the variables named the same as the Tables. I changed this below
Days between = VAR WorksRequested_ = Max('WorksRequested'[DateSentToContractor]) VAR WorksCompleted_ = MAX('WorksCompleted'[DateWorksCompleted]) RETURN DATEDIFF(WorksRequested_, WorksCompleted_, DAY)I got it to work
In the Visual, I added the ID column from the WorksRequested. You can then add the measure
Hope this works for you.
Cheers
Joe
6 Replies
- JoeBarrySolution Sage
Create a measure instead. I will presume that both tables have a shared Dimension table with ProjectID or something similar and a shared date dimension table?
Days between = VAR WorksRequested = Max('WorksRequetsed'[DateSentToContractor]) VAR WorksCompleted = MAX('WorksCompleted'[DateWorksCompleted]) RETURN DATEDIFF(WorksRequested, WorksCompleted, DAY)Add the ProjectID to a visual and then the measure and you will get the days between
Thanks
Joe- Richard_ThomasRegular Visitor
Many thanks for the prompt response and help here, much appreciated. Have tried to run this DAX measure but have come up with the error message The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value
The tables are linked by a common ID but don't have a shared date dimension table.
Any suggestions?
Kind regards
Richard
- JoeBarrySolution Sage
Morning Richard
Is it possible to send me a screenshot of all the Relationships with those two tables?
Thanks