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
Aesir_1103
New Member

Direct and Import Tables for Calculated Measure

Hello Experts,

 

I'm still learning Powerbi and I struggling in the calculation when working on a direct query and import query.

 

I have two tables Rates and Timesheet they have both dates and I need to perform a calculation in Timesheet table. to get the rates of the employee on a specific project on a specific date.

 

First I'm trying to calculate rate but it is not giving me the correct rates.

 

RATE CC2 = CALCULATE(SUM(Rates[Rate]),ALLEXCEPT(Timesheet,Timesheets[Key ID]))

 

Table: RatesImport Table    
      
   DateRateKEYID
 EMP1PR0011/1/202320EMP1PR0014492720
 EMP1PR0021/1/202310EMP1PR0024492710
 EMP2PR0011/1/202320EMP2PR0014492720
 EMP3PR0011/2/202330EMP3PR0014492830
 EMP4PR0021/2/202310EMP4PR0024492810
      
      
Table: Timesheet     
Direct QueryEmployeeProjectDateHoursKEYID
 EMP1PR0011/1/20234EMP1PR0014492720
 EMP1PR0021/1/20234EMP1PR0024492710
 EMP2PR0011/1/20238EMP2PR0014492720
 EMP3PR0011/2/20238EMP3PR0014492830
 EMP4PR0021/2/20238EMP4PR0024492810
1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @Aesir_1103 ,

 

Here are the steps you can follow:

1. Create measure.

Measure_Rate =
SUMX(
    FILTER(ALL(Rates),
    YEAR('Rates'[Date])=YEAR(MAX('Timesheet'[Date]))&&
    MONTH('Rates'[Date])=MONTH(MAX('Timesheet'[Date]))&&
    'Rates'[Employee]=MAX('Timesheet'[Employee])),'Rates'[Rate])
Measure =
[Measure_Rate] * MAX('Timesheet'[Hours])

2. Result:

vyangliumsft_0-1675648184913.png

 

Best Regards,

Liu Yang

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

View solution in original post

4 REPLIES 4
v-yangliu-msft
Community Support
Community Support

Hi  @Aesir_1103 ,

 

Here are the steps you can follow:

1. Create measure.

Measure_Rate =
SUMX(
    FILTER(ALL(Rates),
    YEAR('Rates'[Date])=YEAR(MAX('Timesheet'[Date]))&&
    MONTH('Rates'[Date])=MONTH(MAX('Timesheet'[Date]))&&
    'Rates'[Employee]=MAX('Timesheet'[Employee])),'Rates'[Rate])
Measure =
[Measure_Rate] * MAX('Timesheet'[Hours])

2. Result:

vyangliumsft_0-1675648184913.png

 

Best Regards,

Liu Yang

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

lbendlin
Super User
Super User


Please show the expected outcome based on the sample data you provided.

The expected output should be emp1 for jan 1 cost  120.

 

I need to do hours x rate per employee on each month. 

Don't include the rate in the composite key.  It's a fact column.

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.