Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
MJDS
Frequent Visitor

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 4
lbendlin
Super User
Super User

Use a table visual

Add the case id

Add the Created column twice

Set the first to Min and the second to Max

MJDS
Frequent Visitor

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

How would that look like?

MJDS
Frequent Visitor

I was thinking an average of the allocation days in the y axis and then month from a date table linked to the created value in the model.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.