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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
Centaur
Helper V
Helper V

Apply a Rate

Hello,

 

I am a novice user of Power Query. 

I have a problem I cant figure out. 

Grateful for the assistance. 

here is what I need to do : 

 

  1. I need to apply a rate from a rate table and apply that rate to a pivoted Power Query data set
  2. The rate is dependent upon 2 criteria:  ProjID and the Date. 
  3. I need to apply the rate from the rate table if the record's Date as found in Row 1 (its a header row, pic below) is >[Date From] and <[Date To] in the rate table.  But it must be on [ProjID] match
  4. If the records date is in that range and a match on [ProjID] as found on the rate table then apply that rate from the rate table.   

 

I have 2 Connections in Power Query (the pivoted data set based on the raw excel data and the rate table)

I dont know how I can add the rate to the pivoted data set. 

Maybe its an IF statement?

Below is a link to the file since I cant upload on this website. 

https://1drv.ms/x/s!AkvCjNvcBhpQiPRV5B_j-qzVOgpMhQ?e=PmHewK

the rate table:

Centaur_2-1649207470083.png

 

this is the pivoted table and I want to append the rate above to this table (according to the criteria):

Centaur_1-1649207246809.png

 

 

Any assistance is greatly appreciated.  Thank you

1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @Centaur 

 

You can create a measure to get the rate according to project ID and dates periods. Put this measure into Values of your pivot table. I create the following sample with Power BI. It's similar in Excel's Power Pivot table. 

m_Rate = 
var __date = MAX('data'[dte])
var __projID = MAX('data'[ProjID])
return
CALCULATE(MAX(Rates[Rate]),'Rates'[ProjectID]=__projID,'Rates'[Date From]<=__date,Rates[Date To]>__date)

vjingzhang_0-1649405822883.png

Reference: 

Measures in Power Pivot (microsoft.com)

Excel Data Analysis Class 02: Power Pivot, DAX Formulas, Relationships, Data Modeling & Much More! -...

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

View solution in original post

3 REPLIES 3
mussaenda
Super User
Super User

Hi @Centaur ,

 

Please provide a sample data and your desired output.

Thanks

v-jingzhang
Community Support
Community Support

Hi @Centaur 

 

You can create a measure to get the rate according to project ID and dates periods. Put this measure into Values of your pivot table. I create the following sample with Power BI. It's similar in Excel's Power Pivot table. 

m_Rate = 
var __date = MAX('data'[dte])
var __projID = MAX('data'[ProjID])
return
CALCULATE(MAX(Rates[Rate]),'Rates'[ProjectID]=__projID,'Rates'[Date From]<=__date,Rates[Date To]>__date)

vjingzhang_0-1649405822883.png

Reference: 

Measures in Power Pivot (microsoft.com)

Excel Data Analysis Class 02: Power Pivot, DAX Formulas, Relationships, Data Modeling & Much More! -...

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

Hi, thank you for the response.  I will try to implement but I want to ask a question first.  After looking at the header row, the dates are not in order in my sample file posted. you can see they are out of order if you scroll all the way to the right.  I am not sure why PQ is sorting in this fashion.   I need all of the dates in order from left to right.  Do you see what i am referring to?   do you happen to know why it does this?  I have resorted to using excel but I would like to have a PQ solution as well.   

 

here is a screen shot

must scroll all way to the right.  

Centaur_0-1649432450455.png

 

Helpful resources

Announcements
December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.