• 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

M for nested if not giving me what I want..|Power Query|Excel Forum|My Online Training Hub

You are here: Home / M for nested if not giving me what I want..|Power Query|Excel Forum|My Online Training Hub
Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search|Last Search Results
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 QueryM for nested if not giving me what …
sp_PrintTopic sp_TopicIcon
M for nested if not giving me what I want..
Avatar
Anne Walsh
Member
Members
Level 0
Forum Posts: 100
Member Since:
May 2, 2014
sp_UserOfflineSmall Offline
1
May 9, 2018 - 9:43 pm
sp_Permalink sp_Print

I've created a calculated column in M.  The idea is that the earned revenue is calculated as follows: It's for a subscription model. Amount is paid up front but is "earned" over the year. 

On the contract date, the amount earned is equal to the Amount * 1- Deferred % e.g. if the deferred % is 20%, the amount earned that day will be 80% of the amount plus the balance (20% of the Amount) divided by the number of revenue days i.e. the number of days between the start date and the end date. Otherwise, on all other days of the subscription, the amount earned will be equal to Amount * Deferred% divided by the revenue days. However when I do this calculation and pivot it. I get different results. I have put the desired and actual results in the attached file. I've highlighted in yellow what I am getting and what I should be getting. 

here's the M code - can () be put on various bits of it? 

Text of calculated column

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]* [#"Deferred %"]/[Revenue Days] else [Amount]*[#"Deferred %"]/[Revenue Days]

 

Thank you as always...

Avatar
Mynda Treacy
Admin
Level 10
Forum Posts: 4438
Member Since:
July 16, 2010
sp_UserOfflineSmall Offline
2
May 10, 2018 - 9:14 pm
sp_Permalink sp_Print

Hi Anne,

Yes, you can add () to your Power Query formula to force the order of calculation, but it's not necessary for the 'if' itself, as you know.

I'm not sure where the "PivotTable" is that you refer to in your file and there's no query or yellow highlight. I'm having trouble seeing how you got the incorrect result without seeing the workings.

Mynda

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

That's the bit I am missing - the () . All I wanted was to review the formula...will try that now! Thank you..

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Jessica Stewart, Dieneba NDIAYE, Mark Carlson, Debi Morgan
Guest(s) 11
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:
Debi Morgan
yashal minahil
Oluwadamilola Ogun
Yannik H
dectator mang
Francis Drouillard
Orlando Inocente
Jovitha Clemence
Maloxat Axmatovna
Ricardo Freitas
Forum Stats:
Groups: 3
Forums: 24
Topics: 6201
Posts: 27185

 

Member Stats:
Guest Posters: 49
Members: 31861
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.