Forum Discussion

MJDS's avatar
MJDS
Frequent Visitor
2 years ago

Merge rows on single id in Direct Query

Hi everyone,

 

The background

I'm trying to build a performance management dashboard for a multi-stage customer complaints process.  The data comes from a case management/CRM system and is shared by a third party supplier through direct query.  Unfortunately I can't share any of the actual data.

 

The story so far
I'm trying to use data from the Case_Audit table to track how long things are in a queue waiting to picked up.  I've filtered the data in Power BI by history type 'Case re-assigned' and by contains 'Allocation Queue'.

 

Here is what the data looked like:

CaseIdCreatedHistory typeDescription
000101/08/24Case re-assignedAssigned from John Smith to Allocation Queue
000104/08/24Case re-assignedAssigned from Allocation Queue to Linda Brown
000202/08/24Case re-assignedAssigned from Mary O'Brien to Allocation Queue
000204/08/24Case re-assignedAssigned from Allocation Queue to John McPhee
............

 

What I've done so far

I created the following DAX calculated columns:

 

Allocation direction = IF(CONTAINSSTRING('Case_Audit'[Description],"to Allocation Queue"),"To","From")
Allocated date = IF(Case_Audit[Allocation direction]="To",'Case_Audit'[Created],BLANK())
Re-allocated date = IF(Case_Audit[Allocation direction]="From",'Case_Audit'[Created],BLANK())

 

And the following DAX measures:

 

Allocated date measure = MAX('Case_Audit'[Allocated date])
Re-allocated measure = MAX('Case_Audit'[Re-allocated date])
Allocation days = DATEDIFF('Case_Audit'[Allocated date measure],'Case_Audit'[Re-allocated measure],DAY)

 

 This is how my table looks at the moment:

CaseIdCreatedAllocated date measureRe-allocated measureAllocation days
000101/08/2401/08/24  
000104/08/24 04/08/24 
000202/08/24 02/08/24  
000204/08/24 04/08/24 
...............

 

The problem

I need to find a method that works in Direct Query and doesn't use Power Query to collapse the data so that it looks like this:

CaseIdCreatedAllocated date measureRe-allocated measureAllocation days
000101/08/2401/08/2404/08/243
000202/08/2402/08/2404/08/242
...............

 

Thanks in advance!

4 Replies

  • Use a table visual

    Add the case id

    Add the Created column twice

    Set the first to Min and the second to Max

    • MJDS's avatar
      MJDS
      Frequent Visitor

      Thanks, is there a way I could also use this method in a clustered column visual?