• 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

Is there anything like Min/Max for numbers in PQ|Power Query|Excel Forum|My Online Training Hub

You are here: Home / Is there anything like Min/Max for numbers in PQ|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 QueryIs there anything like Min/Max for …
sp_PrintTopic sp_TopicIcon
Is there anything like Min/Max for numbers in PQ
Avatar
Rainer Stahl

Active Member
Members
Level 0
Forum Posts: 5
Member Since:
October 17, 2020
sp_UserOfflineSmall Offline
1
June 27, 2022 - 5:33 pm
sp_Permalink sp_Print

Hi,

currently I'm looking how to manage something like 'truncate a text (<txt>) by 1 character of it's length', which in general is pretty easy with

Text.Start(<txt>, Text.Length(<txt>)-1)

But I want to make shure, that this will not generate an error in case the <txt> is empty. Therefore I'd like to write something like

Text.Start(<txt>, MAX(0,Text.Length(<txt>)-1))

Any idea? Thanks!

RaiSta

sp_AnswersTopicSeeAnswer See Answer
Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1512
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
2
June 28, 2022 - 8:13 am
sp_Permalink sp_Print

Hi RaiSta,

You could try

if Text.Length(<txt>) > 0 then Text.Start(<txt>, MAX(0,Text.Length(<txt>)-1)) else null

Regards

Phil

sp_AnswersTopicAnswer
Answers Post
Avatar
Velouria
London or thereabouts
Moderator
Members


Trusted Members

Moderators
Level 4
Forum Posts: 613
Member Since:
November 1, 2018
sp_UserOfflineSmall Offline
3
June 28, 2022 - 6:20 pm
sp_Permalink sp_Print

You could also do something like:

Text.Start(<txt>, List.Max({0,Text.Length(<txt>)-1})))

 

Just bear in mind that you are likely to end up with a mix of empty text and null values in the resulting column.

Avatar
Rainer Stahl

Active Member
Members
Level 0
Forum Posts: 5
Member Since:
October 17, 2020
sp_UserOfflineSmall Offline
4
June 29, 2022 - 6:34 am
sp_Permalink sp_Print

Thanks Philip, thanks Velouria,

both answers seem to fulfil my needs, but I can mark only one to be an ('the') answer... so I took the first.

Will see, as soon as I'm back to the topic of interest how it works in 'free nature' - but this could take some time. And I will not set it to 'null', but to the original text, because only 'truncatable' texts will be modified. This will be just a safety issue, to cover rare cases outside my test environments, that the query will not throw an error which might not be able to be handled from persons using my design. You know: it works well in all tested cases and 99.xxx% of all applications. But after long time of working all of a sudden an 'unexplainable' error shows up, me maybe no longer at hand or whatever else. Just to be prepared...

Thanks for your contributions,

RaiSta

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Brian Pham, drsven
Guest(s) 9
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:
drsven
Annie Witbrod
wahab tunde
Cong Le Duc
Faisal Bashir
Ivica Cvetkovski
Blaine Cox
Shankar Srinivasan
riyepa fdgf
Hannah Cave
Forum Stats:
Groups: 3
Forums: 24
Topics: 6205
Posts: 27211

 

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