Can someone help me in converting the following code from a calculated column to a DAX measure so that I can use it across multiple queries. And maybe even explain the general mechanics for deriving the solution on my own?
Overlaps_A_Run =
VAR _endDate = 'LREMerged'[Test Run End Date]
VAR _startDate = 'LREMerged'[Test Run Start Date]
VAR last =
MAXX (
FILTER (
'LREMerged',
'LREMerged'[Test Run End Date]
< _endDate
),
'LREMerged'[Test Run End Date]
)
VAR next =
MINX (
FILTER (
'LREMerged',
'LREMerged'[Test Run Start Date]
> _startDate
),
'LREMerged'[Test Run Start Date]
)
RETURN
IF (
ISBLANK ( last )
&& next > 'LREMerged'[Test Run End Date]
|| ISBLANK ( next )
&& last < 'LREMerged'[Test Run Start Date],
0,
IF (
last > 'LREMerged'[Test Run Start Date]
|| next < 'LREMerged'[Test Run End Date],
1,
0
)
)
Hi @jsonify i @j, I noticed you didn’t provide a PBIX file. Providing one will help users and experts find a solution to your inquiry faster and better.
A perfect initial question includes all of the following:
A clear explanation of the problem you are experiencing
A mockup of the results you want to achieve
Your current work-in-progress PBIX file
Your underlying data file (to allow us to go into Power Query if necessary to transform your data and/or data model – often DAX questions really end up being data modeling solutions)
Your calculated column tells you if each run date is overlapping another run.
For instance for the Run ID 1, the results is 1 because the dates from 02/07/2019 9AM to 02/07/2019 5PM overlaps the dates of the Run ID 2.
To better show you the calculated column result, I have created a column for each variable in the formula.
The only differences are that you need to use “SELECTEDVALUE” to have the value of the column and you need to add “ALLSELECTED” in the last and next variables to have access to all the table and not just the specific rows.
Hi @jsonify, we’ve noticed that no response has been received from you since September 24.
We just want to check if you still need further help with this post? In case there won’t be any activity on it in the next few days, we’ll be tagging this post as Solved.