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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
senad
Frequent Visitor

Turn multiple rows with same company into one row

Hello, 

 

I'm having trouble figuring this out. Any help is appreciated, thank you. 
I have a dataset, sampled below:

 

 

DealID#DealDateExitDate
910-09T1  
202-76T12/22/2013 
849-35T1  
362-32T11/30/20151/30/2015
531-76T18/13/20158/13/2015
606-25T111/9/201511/9/2015
1709-89T14/30/2020 

 

 

 

The task is to, for each # (which represents company), take the earliest DealDate, and Latest ExitDate, and turn it into one row. Deal ID isn't needed, just there to represet each time a deal was made in database. 

 

So for this company, company 1, i would like for it to have only (First Deal) 2/22/2013 and (Lateset Exit)11/9/2015. 

1 ACCEPTED SOLUTION
saidalkharusi
New Member

Hi Senad, 

 

1. Let's call your current table Detailed. We can start by creating a mini table called Summary that includes the distinct Company IDs:

Summary = DISTINCT(Detailed[Company ID])
 
2. In model view, create a relationship between Company ID in Summary table and Company ID in Detailed table.
 
3. In summary table, add a new column for first deal date. We'll use FIRSTDATE to get first date DealDate column in Detailed Table, and CALCULATE to filter by Company ID:
First Deal Date = CALCULATE(FIRSTDATE(Detailed[DealDate]),ALL(Detailed[Company ID]))
 
4.  We'll do the same for first exit date:
First Exit Date = CALCULATE(FIRSTDATE(Detailed[ExitDate]),ALL(Detailed[Company ID]))
 
Hope this helps. 

View solution in original post

1 REPLY 1
saidalkharusi
New Member

Hi Senad, 

 

1. Let's call your current table Detailed. We can start by creating a mini table called Summary that includes the distinct Company IDs:

Summary = DISTINCT(Detailed[Company ID])
 
2. In model view, create a relationship between Company ID in Summary table and Company ID in Detailed table.
 
3. In summary table, add a new column for first deal date. We'll use FIRSTDATE to get first date DealDate column in Detailed Table, and CALCULATE to filter by Company ID:
First Deal Date = CALCULATE(FIRSTDATE(Detailed[DealDate]),ALL(Detailed[Company ID]))
 
4.  We'll do the same for first exit date:
First Exit Date = CALCULATE(FIRSTDATE(Detailed[ExitDate]),ALL(Detailed[Company ID]))
 
Hope this helps. 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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