Results 1 to 6 of 6

Power Query nested if evaluation order

Threaded View

  1. #1
    Forum Contributor
    Join Date
    08-03-2021
    Location
    London
    MS-Off Ver
    365
    Posts
    647

    Power Query nested if evaluation order

    Hi,
    I have a question re the order of using nested if's in PQ,

    I want to make 'numbers" = 1000 and text strings thant start with 'a' = "AAA , if first tried this,

    Does not work;

     Table.ReplaceValue( Source, "", "" , (x,y,z)=> 
                          if Text.Start(x,1) = "a" then "AAA" else 
                           if Value.Type(x) = type number then 10000 else x , 
                                 Cols )
    The first if does but I get an error for numbers, so I changed the order and this works

    Works;
    Table.ReplaceValue( Source, "", "", (x,y,z)=> 
                           if Value.Type(x) = type number then 10000  else 
                             if Text.Start( x,1) = "a" then "AAA" else x , 
                                 Cols )
    I can't see why they outcome should differ? I have tried by putting an if to text if it is text before taking the first value but still no good,

    Table.ReplaceValue( Source, "", "" , 
                                                   (x,y,z)=> 
                                                            if Value.Type(x) = type text then if Text.Start(x,1)= "a" then "AAA" else
                                                              if Value.Type(x) = type number then 1000 else x else x ,
                                                                   Cols )
    Can someone point out the evaluation order ?

    Richard.
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 1
    Last Post: 07-14-2023, 10:15 AM
  2. Replies: 1
    Last Post: 03-05-2023, 06:55 AM
  3. Power Query refresh order
    By Steveapa in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-20-2021, 09:58 AM
  4. Power query changes line order
    By afgi in forum Excel Charting & Pivots
    Replies: 4
    Last Post: 04-29-2020, 05:55 PM
  5. [SOLVED] Power Query - how to keep order of the source table
    By afgi in forum Excel Charting & Pivots
    Replies: 9
    Last Post: 02-26-2020, 02:59 AM
  6. Power Query Refresh Order
    By Steveapa in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-20-2019, 11:02 PM
  7. Sub-Forum for Excel Power Tools (Power Query, Power Pivot & Power BI)
    By chullan88 in forum Suggestions for Improvement
    Replies: 10
    Last Post: 06-28-2018, 02:25 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1