cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
TheBishopEmpire
Frequent Visitor

If Then Else with AND operator (acting as a BETWEEN)

I'm in Power Query editor. I've created a new Customer Column called "EmploymentDuration_Days". This field returns the number of days the employee was employed with the company. I'm trying to evaluate the days into something more common for the user. For instance...

if [EmploymentDuration_Days] >= 181 and [EmpoloymentDuration_Days] < 365 then "6 Months-1 Year" else "Some Other Text Here"

...ultimately this will be 7 itterations of the if() but need to understand why the example above returns the error below:

Expression.Error: The field 'EmpoloymentDuration_Days' of the record wasn't found.
Details:
HiredDate=9/6/2001 12:00:00 AM
RetiredDate=7/9/2002 12:00:00 AM
EmploymentDuration_Days=306
EmploymentDuration=[Error]

1 ACCEPTED SOLUTION
edhans
Super User
Super User

I'd have to see your full M code and example, but your error copied has EmploymentDuration_Days mispelled. It might be as simple as that.

'EmpoloymentDuration_Days'



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

3 REPLIES 3
edhans
Super User
Super User

I'd have to see your full M code and example, but your error copied has EmploymentDuration_Days mispelled. It might be as simple as that.

'EmpoloymentDuration_Days'



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

That was merely a typo and I'm truly thankful for your eagle-eye. The spelling error corrected my error.  

Great! My first go-to issue is typos or something not the same case. Employment_Days will not match Employment_days for example and throw the same error.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Helpful resources

Announcements
Power BI Show Episode 10 Recap

The Power BI Community Show

Watch the playback when Amit Chandak, a Power BI Super User, demos how to use Field Parameters to make reports more dynamic.

Power BI Dev Camp Session 26

New Date - Check it Out!

Mark your calendars and join us on Thursday, October 6 at 11a PDT for a great session with Ted Pattison!

Health and Life Sciences Power BI User Group

Health and Life Sciences Power BI User Group

Power BI specialists at Microsoft have created a community user group where customers in the provider, payor, pharma, health solutions, and life science industries can collaborate.

Ignite 2022

What's Next at Microsoft Ignite 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Top Kudoed Authors