+ Reply to Thread
Results 1 to 3 of 3

Power Query (Last Two Columns Reference - Hardcoding Problem)

  1. #1
    Registered User
    Join Date
    07-29-2020
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    36

    Power Query (Last Two Columns Reference - Hardcoding Problem)

    Hey. So basically I want to do something where the last two columns of a table in power query will have their average taken. This is what it currently looks like:
    https://gyazo.com/aa664bf02d6b17f65761ee745428b163

    Does anyone know how I can stop the hardcoding of the Week 38 and Week 39, to instead just reference the last two columns of the previous step? Thanks.

    I have attached a sample file if it's of any use.

    Oh, I also have an issue with reordering the columns too because the advanced editor hardcodes the order, so when new weeks gets added, the order get's messed up unless you go back and adjust (not the end of the world, but a bit annoying, and it would be nice to avoid this issue). Thanks.
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    07-29-2020
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    36

    Re: Power Query (Last Two Columns Reference - Hardcoding Problem)

    Thought I would at least give it a go myself even if I have no idea what I am doing with m code. I just tried:
    Please Login or Register  to view this content.
    But it says
    "Expression.SyntaxError: Token RightParen expected."

    Any thoughts on how I can fix this? I don't really get why it's causing problems.
    Last edited by alansidman; 10-04-2020 at 10:46 AM.

  3. #3
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,532

    Re: Power Query (Last Two Columns Reference - Hardcoding Problem)

    This is more of a work around than a solution, as the averaging is done on the Daily Sales sheet rather than in Power Query.
    Column G calculates the average of the last two weeks using: =AVERAGE(SUMIFS(H7:DL7,H$1:DL$1,AGGREGATE(14,6,H$1:DL$1/(H7:DL7<>""),1)-1),SUMIFS(H7:DL7,H$1:DL$1,AGGREGATE(14,6,H$1:DL$1/(H7:DL7<>""),1)))
    Note that for this to work the week numbers in row 1 are converted to numbers then custom formatted: "Week" 0
    I feel that from this point you will be able to use Power Query to produce the table on the Weekly Sales sheet the way you would like it.
    Let us know if you have any questions.
    Attached Files Attached Files
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

+ 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. Reference your excel formula to power query table
    By ninadkadu in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-27-2020, 01:39 AM
  2. Power Query / Power pivot : M2M relationships problem
    By almourasel in forum Excel General
    Replies: 6
    Last Post: 03-26-2020, 05:33 PM
  3. Replies: 4
    Last Post: 02-17-2020, 06:03 AM
  4. Custom Permutations Column in Power Query from two columns in the same Query
    By PaintPaddy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-11-2019, 02:48 PM
  5. How to concatenate cell reference and text in Power Query?
    By basispoints in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-06-2019, 11:22 AM
  6. 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
  7. Problem consolidation with Power Query
    By toblju in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-12-2016, 11:02 AM

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