Forum Discussion
Conditional Merge Queries based on column value
- Anonymous3 years ago
Hi oscargushiken ,
I have created a simple sample, please refer to it to see if it helps you.
Create a measure.
result = CALCULATE ( MAX ( 'date'[JOB_CODE] ), FILTER ( ALL ( 'date' ), 'date'[EMPLOYEE_ID] = SELECTEDVALUE ( 'date'[EMPLOYEE_ID] ) && 'date'[Index] = SELECTEDVALUE ( 'date'[Index] ) + 1 ) )Or a column.
Column = CALCULATE ( MAX ( 'date'[JOB_CODE] ), FILTER ( ALL ( 'date' ), 'date'[EMPLOYEE_ID] = EARLIER ( 'date'[EMPLOYEE_ID] ) && 'date'[Index] = EARLIER ( 'date'[Index] ) + 1 ) )How to Get Your Question Answered Quickly
If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .
Best Regards
Community Support Team _ Polly
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. - 3 years ago
Hi,
This calculated column formula works
Column = LOOKUPVALUE(Data[JOB_CODE],Data[DATE],CALCULATE(MAX(Data[DATE]),FILTER(Data,Data[EMPLOYEE_ID]=EARLIER(Data[EMPLOYEE_ID])&&Data[DATE]<EARLIER(Data[DATE]))),Data[EMPLOYEE_ID],Data[EMPLOYEE_ID])Hope this helps.
Hi oscargushiken ,
I have created a simple sample, please refer to it to see if it helps you.
Create a measure.
result =
CALCULATE (
MAX ( 'date'[JOB_CODE] ),
FILTER (
ALL ( 'date' ),
'date'[EMPLOYEE_ID] = SELECTEDVALUE ( 'date'[EMPLOYEE_ID] )
&& 'date'[Index]
= SELECTEDVALUE ( 'date'[Index] ) + 1
)
)
Or a column.
Column =
CALCULATE (
MAX ( 'date'[JOB_CODE] ),
FILTER (
ALL ( 'date' ),
'date'[EMPLOYEE_ID] = EARLIER ( 'date'[EMPLOYEE_ID] )
&& 'date'[Index]
= EARLIER ( 'date'[Index] ) + 1
)
)
How to Get Your Question Answered Quickly
If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .
Best Regards
Community Support Team _ Polly
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- oscargushiken3 years agoFrequent Visitor
Thanks v-polly-msft, the .pbix file helps a lot and works like a charm.