+ Reply to Thread
Results 1 to 7 of 7

Power Query Add Column with formula

  1. #1
    Registered User
    Join Date
    02-02-2024
    Location
    Glasgow, Scotland
    MS-Off Ver
    365
    Posts
    36

    Power Query Add Column with formula

    Hi

    I'm aware you can't add, in Power Query, a formula that when closed/loaded/refreshed to excel runs automatically, but is there a way to add a column in Power Query with anything in it that is ignored by Power Query but forwards to Excel as text?

    Eg, I need to add this formula, but PQ I think is seeing some of it and trying to action it. I just need the whole cells ignored and not run:
    =IF(L2-"","",IF(COUNT(L$1:L$1,L2)>=1,"",L2))

    I've tried adding a custom column and using = "=IF(L2-"","",IF(COUNT(L$1:L$1,L2)>=1,"",L2))" but all I get is an error. I can add plain text fine, but anything else errors.

    Again I'm aware this likely will need dragged down the column, but that's a simple step.

    thanks

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    81,597

    Re: Power Query Add Column with formula

    No, it can't be done.

    You might be able to adapt this technique to add a formula column: https://exceleratorbi.com.au/self-re...s-power-query/
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Expert
    Join Date
    01-05-2013
    Location
    Singapore
    MS-Off Ver
    H&B2016 & H&B2021
    Posts
    3,081

    Re: Power Query Add Column with formula

    Try creating the column directly in the table loaded by PQ.

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    81,597

    Re: Power Query Add Column with formula

    You can't do that - it's not possible to add a formula to an empty column in a PQ-generated table as it will be removed each time you refresh. You'd have to add the formula back again manually every time.

    @BarryWhitelaw - thanks for the rep. Glad to have helped.

  5. #5
    Forum Expert
    Join Date
    01-05-2013
    Location
    Singapore
    MS-Off Ver
    H&B2016 & H&B2021
    Posts
    3,081

    Re: Power Query Add Column with formula

    Please see attached workbook.
    Attached Files Attached Files

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    81,597

    Re: Power Query Add Column with formula

    OK - I misunderstood your suggestion - sorry. I thought you were saying that you were adding the column via the query.

    I suspect that the OP's requirement was more complex, though, which is why they went with my suggestion.

  7. #7
    Forum Expert
    Join Date
    01-05-2013
    Location
    Singapore
    MS-Off Ver
    H&B2016 & H&B2021
    Posts
    3,081

    Re: Power Query Add Column with formula

    Haha.. no worries..

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Power Query Custom Column Formula
    By sharonca in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-01-2023, 03:16 PM
  2. Replies: 10
    Last Post: 06-25-2020, 12:19 AM
  3. [SOLVED] Power Query - excel formula translation into Power Query
    By afgi in forum Excel Charting & Pivots
    Replies: 7
    Last Post: 02-19-2020, 03:38 AM
  4. Replies: 4
    Last Post: 02-17-2020, 06:03 AM
  5. [SOLVED] Power Query Custom Column Formula
    By whiskeybravo91 in forum Excel Charting & Pivots
    Replies: 4
    Last Post: 08-06-2018, 11:10 AM
  6. Power Query Custom Column Formula
    By whiskeybravo91 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-06-2018, 09:57 AM
  7. Help with Power Query Custom Column Formula
    By travis.cook21 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-16-2016, 01:45 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