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
Anonymous
Not applicable

How to link csv file with excel file with a key column

Hello Power BI Community,

 

I'm a novice in Power BI and I'm currently struggling with linking data from a .CSV file with an excel file through a key column.

 

On the one hand, the .CSV file which I would name "Deliveries" contains a list of deliveries prepared during the day.

Basically, the "Deliveries' file looks like this :

Delivery number (String type)Date of preparation (Date type in dd/MM/yyyy format)Hour of preparation (Time type in hh:mm:ss format)
0000101/04/202108:01:59
0000201/04/202108:35:42
0000301/04/202108:52:06
0000401/04/202109:03:18
0000501/04/202109:19:26
0000601/04/202109:28:32
0000701/04/202109:47:41
0000801/04/202110:15:36
0000901/04/202110:28:14
0001001/04/202110:51:22

 

So in the "Deliveries" file I've got 10 deliveries prepared on 01/04/2021 :

- 3 deliveries prepared in the 8h time slot

- 4 deliveries prepared in the 9h time slot

- 3 deliveries prepared in the 10h time slot

 

On the other hand, the excel file which I would name "Capacity" contains the production capacity of the team for the day and would be updated before the start of the day (file dropped in a declared folder).

The "Capacity" file looks like this :

Date

(Date type in dd/MM/yyyy format)

Hour time slot

(Time type in hh:mm:ss format)

Amount of preparators planned for the time slot (float type)
01/04/202108:00:004,5
01/04/202109:00:006
01/04/202110:00:006
01/04/202111:00:003
01/04/202112:00:006
01/04/202113:00:006
01/04/202114:00:006
01/04/202115:00:004,5
01/04/202116:00:006
01/04/202117:00:006
01/04/202118:00:006
01/04/202119:00:003

 

I've created a measure named "hourly productivity target" based on the product of "Amount of preparators planned for the time slot" and a constant named "Target Productivity" = 10.

The DAX expression is : 

hourly productivity target = 'Capacity'[Amount of preparators planned for the time slot] * Measures[Target Productivity]
 
What I would like to calculate and show in the report is for each time slot of the day, the hourly productivity target versus the effective hourly productivity. The result would look like this :

Date

(Date type in dd/MM/yyyy format)

Hour time slot

(Time type in hh:mm:ss format)

Amount of preparators planned for the time slot (float type)Hourly productivity targetEffective Hourly productivityDelta
01/04/202108:00:004,5453-42
01/04/202109:00:006604-56
01/04/202110:00:006603-57
01/04/202111:00:00330  
01/04/202112:00:00660  
01/04/202113:00:00660  
01/04/202114:00:00660  
01/04/202115:00:004,545  
01/04/202116:00:00660  
01/04/202117:00:00660  
01/04/202118:00:00660  
01/04/202119:00:00330  
 
The DAX expression for effective hourly productivity is 
= CALCULATE(COUNT(Deliveries[Delivery number]), Deliveries[Date of preparation] = TODAY()) + 0
When I create a table with only "Deliveries" data it looks good. I can show :

Date of preparation

(Date type in dd/MM/yyyy format)

Hour time slot

(Time type in hh:mm:ss format)

Effective Hourly productivity
01/04/202108:00:003
01/04/202109:00:004
01/04/202110:00:003
 
In the data model view, I create a join between "Deliveries" and "Capacity" through "Deliveries".Hour of preparation and "Capacity".Hour time slot.
 
And when I add the "Effective hourly productivity" in the table result it looks like it can't match the data between the 2 datasets.
 
Could you please help me and tell me what am i doing wrong ?
Feel free to ask for more information.
Best regards.
 
Vincent.
 
1 ACCEPTED SOLUTION
v-deddai1-msft
Community Support
Community Support

Hi @Anonymous ,

 

You need to create a new column in Deliveries:

 

new Hour of preparation = TIME(HOUR(Deliveries[Hour of preparation (Time type in hh:mm:ss format)]),0,0)

 


Capture.PNG

 

Then you can create relationship between capcity and deliveries by the new column

For your expected output, you can use the following measure:

 

hourly productivity target = MAX(Capacity[Amount of preparators planned for the time slot (float type)])*10

effective hourly productivity = CALCULATE(COUNT(Deliveries[Delivery number (String type)]),FILTER(Deliveries,Deliveries[Date of preparation (Date type in dd/MM/yyyy format)] = MAX(Capacity[Date]) && Deliveries[new Hour of preparation] = MAX(Capacity[Hour time slot])))

Delta = [effective hourly productivity]-[hourly productivity target]

 

Capture1.PNG

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Best Regards,

Dedmon Dai

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Thank you very much for all the details, Dedmon Dai.

It works perfectly ! 😁

v-deddai1-msft
Community Support
Community Support

Hi @Anonymous ,

 

You need to create a new column in Deliveries:

 

new Hour of preparation = TIME(HOUR(Deliveries[Hour of preparation (Time type in hh:mm:ss format)]),0,0)

 


Capture.PNG

 

Then you can create relationship between capcity and deliveries by the new column

For your expected output, you can use the following measure:

 

hourly productivity target = MAX(Capacity[Amount of preparators planned for the time slot (float type)])*10

effective hourly productivity = CALCULATE(COUNT(Deliveries[Delivery number (String type)]),FILTER(Deliveries,Deliveries[Date of preparation (Date type in dd/MM/yyyy format)] = MAX(Capacity[Date]) && Deliveries[new Hour of preparation] = MAX(Capacity[Hour time slot])))

Delta = [effective hourly productivity]-[hourly productivity target]

 

Capture1.PNG

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Best Regards,

Dedmon Dai

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.