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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.