• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
    • Password Reset
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

Error message in M function|Power Query|Excel Forum|My Online Training Hub

You are here: Home / Error message in M function|Power Query|Excel Forum|My Online Training Hub
Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumPower QueryError message in M function
sp_PrintTopic sp_TopicIcon
Error message in M function
Avatar
Anne Walsh
Member
Members
Level 0
Forum Posts: 100
Member Since:
May 2, 2014
sp_UserOfflineSmall Offline
1
May 3, 2018 - 7:42 pm
sp_Permalink sp_Print

First of all, a big shout out to the truly BRILLIANT Power Query course Mynda has done. It has saved me SO MUCH time and I'm enjoying getting to grips with M (ooh, makes me think I'm James Bond...better stop now...). 

I have created a Custom column and here is the code:

if [#"Deferred %"]=1 or [#"Deferred %"]=0 or [In Contract Date]="No" then 0 else if [#"S&M Contract Start date"]=[Revenue Date] then [Amount]*1-[#"Deferred %"] + [Amount]/[Revenue Days] else [Amount]/[Revenue Days]

When I created it, it said "no syntax errors" but when I tried to run it, I got this message..

Expression. Error: We cannot apply operator / to types Number and Duration

Details: 

Operator =/

Left =27000

Right=365.00:00:00

 

"Revenue Days" is the difference between a Start Date and an End Date. That has been formatted as a whole number. 

I have formatted both Start Date and End Date as Date.  I reckon it's something simple that I am missing. Thank you.

Avatar
Mynda Treacy
Admin
Level 10
Forum Posts: 4447
Member Since:
July 16, 2010
sp_UserOfflineSmall Offline
2
May 4, 2018 - 9:00 am
sp_Permalink sp_Print

Hi Anne,

Great to hear you're reaping huge rewards with Power Query. Spread the word. It's surprising how many people still aren't using it.

Now, on to your error. It seems like Revenue Days is still a Duration type, or at least being interpreted as such. When I add a column to subtract a Start Date from an End Date I get this line of code:

 #"Inserted Date Subtraction" = Table.AddColumn(#"Changed Type", "Subtraction", each Duration.Days([End] - [Start]), Int64.Type)

 

You can see the data type is Int64.Type

Is that what you get?

Mynda

Avatar
Anne Walsh
Member
Members
Level 0
Forum Posts: 100
Member Since:
May 2, 2014
sp_UserOfflineSmall Offline
3
May 4, 2018 - 5:14 pm
sp_Permalink sp_Print

That's what I am getting. How should I rectify it? Thanks. I'm now tantalisingly close to getting this project over the line. Planning to finish it off with an icing of parameter queries (as you do! 🙂 

Avatar
Mynda Treacy
Admin
Level 10
Forum Posts: 4447
Member Since:
July 16, 2010
sp_UserOfflineSmall Offline
4
May 5, 2018 - 7:55 pm
sp_Permalink sp_Print

Hi Ann,

That should give you the correct results. He's my sample file that works. It might help you troubleshoot.

If not, please send your Excel file so we can see what's going on.

Mynda

Avatar
Anne Walsh
Member
Members
Level 0
Forum Posts: 100
Member Since:
May 2, 2014
sp_UserOfflineSmall Offline
5
May 7, 2018 - 10:51 pm
sp_Permalink sp_Print

hi Mynda

I got all that bit working - I basically rolled it back, and did the date re-formatting at the beginning. So that's working 🙂 Thank you 🙂 

Now I have another dilemma. I have set up a parameter query  that references a date as per your excel-lent video 🙂 . Basically the user will input this date. All income earned before this date is called "Not deferred", all income after it is "Deferred". I set up a column called Deferred Income? 

= Table.AddColumn(#"Added Custom5", "Deferred Income?", each if [Revenue Date]<=Parameter_Deferred_Date then "Not Deferred" else "Deferred")

However I get the error

Expression.Error: We cannot apply operator < to types DateTime and Date.
Details:
Operator=<
Left=30/06/2018 00:00:00
Right=01/01/2013

Again, probably a simple thing...but what am I missing? Thanks 

Avatar
Catalin Bombea
Iasi, Romania
Admin
Level 10
Forum Posts: 1807
Member Since:
November 8, 2013
sp_UserOfflineSmall Offline
6
May 8, 2018 - 9:38 pm
sp_Permalink sp_Print

Hi Anne

As you guessed already, it's a simple error, hope the colors will help you see what the text already tells you:

We cannot apply operator < to types DateTime and Date.

[Revenue Date]<=Parameter_Deferred_Date

Left=30/06/2018 00:00:00     Right=01/01/2013

You have to change Revenue Date to Date type, OR Parameter to DateTime type. It does not matter which one you change, both should have the same data type.

Avatar
Anne Walsh
Member
Members
Level 0
Forum Posts: 100
Member Since:
May 2, 2014
sp_UserOfflineSmall Offline
7
May 9, 2018 - 9:34 pm
sp_Permalink sp_Print

Excellent - again, I went back and fixed this and it worked...sigh, it's always the simple things...

Avatar
Mynda Treacy
Admin
Level 10
Forum Posts: 4447
Member Since:
July 16, 2010
sp_UserOfflineSmall Offline
8
March 4, 2021 - 12:05 pm
sp_Permalink sp_Print

Hi Keith,

It's not clear where the error is occurring, but presumably it's the "Filtered Rows3" step. The error is telling you that you're trying to reference a whole table instead of a record when performing your logical test.

Please start a new topic and attach your file or a small sample file that illustrates what you're trying to do.

Mynda

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Aron Samuels
Guest(s) 10
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 870
Purfleet: 412
Frans Visser: 346
David_Ng: 306
lea cohen: 219
A.Maurizio: 202
Jessica Stewart: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
Hayden Hao
Angela chen
Sean Moore
John Chisholm
vexokeb sdfg
John Jack
Malcolm Toy
Ray-Yu Yang
George Shihadeh
Naomi Rumble
Forum Stats:
Groups: 3
Forums: 24
Topics: 6212
Posts: 27239

 

Member Stats:
Guest Posters: 49
Members: 31891
Moderators: 3
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.