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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
SJHALANI
Helper I
Helper I

Converting Excel formula to Power Query

Hi,

I had an excel which had lots of formula and thus it made its working very slow. Now I am in the process of migrating my excel formulas to Power query. I have the below formula in Excel which I am not sure how to convert to PQ formula. Any help would be greatly appreciated.

=IFERROR(@IF([@key]>0,SWITCH([@[Fbase_rate_monthly_fraction]],"Based on Fixed Hours", [@[Total Hours]]<=[@[Ffixed_hours]],"Based on Net Hours", [@[Total Hours]] <= [@[Fnet_hours]],"Based on Total Hours", [@[Total Hours]] <= [@[Ftotal_hours]],"N/A", [@[Total Hours]] <=[@[Ftotal_hours]],FALSE),""),"")

TIA!

1 ACCEPTED SOLUTION
m_dekorte
Super User
Super User

Hi @SJHALANI 

 

Give this a go, it assumes that all field names (everything in square brackets) correspond to column names in your table. Add a custom column and enter this in the formula section:

 

try
  if [key] > 0 then {
    [Total Hours] <= [Ffixed_hours], 
    [Total Hours] <= [Fnet_hours], 
    [Total Hours] <= [Ftotal_hours], 
    [Total Hours] <= [Ftotal_hours], 
    false
  }{ List.PositionOf(
      {
          "Based on Fixed Hours", 
          "Based on Net Hours", 
          "Based on Total Hours", 
          "N/A", 
          false
      }, 
      [Fbase_rate_monthly_fraction]
  )}
else ""
otherwise ""

 

I hope this is helpful

View solution in original post

1 REPLY 1
m_dekorte
Super User
Super User

Hi @SJHALANI 

 

Give this a go, it assumes that all field names (everything in square brackets) correspond to column names in your table. Add a custom column and enter this in the formula section:

 

try
  if [key] > 0 then {
    [Total Hours] <= [Ffixed_hours], 
    [Total Hours] <= [Fnet_hours], 
    [Total Hours] <= [Ftotal_hours], 
    [Total Hours] <= [Ftotal_hours], 
    false
  }{ List.PositionOf(
      {
          "Based on Fixed Hours", 
          "Based on Net Hours", 
          "Based on Total Hours", 
          "N/A", 
          false
      }, 
      [Fbase_rate_monthly_fraction]
  )}
else ""
otherwise ""

 

I hope this is helpful

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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