Results 1 to 5 of 5

Power Query Variables and how to use them

Threaded View

Dicken Power Query Variables and how... 08-07-2022, 08:53 AM
alansidman Re: Power Query Variables and... 08-07-2022, 09:08 AM
Dicken Re: Power Query Variables and... 08-07-2022, 10:00 AM
Bo_Ry Re: Power Query Variables and... 08-08-2022, 02:00 PM
Dicken Re: Power Query Variables and... 08-08-2022, 02:14 PM
  1. #1
    Forum Contributor
    Join Date
    08-03-2021
    Location
    London
    MS-Off Ver
    365
    Posts
    777

    Power Query Variables and how to use them

    Hi,
    I recently had to use a variable in power query , I could not get it to accept the column name ,but haven't been able to find much information on how to use them. I had to declare the start date (sdate) as a variable to use with List.Select, but then had to also make the rest a variable also up to that point it had just been ? whatever not being a VAR is ?
    Work book attached ; queries 'typed in ' and "VAR steps" .


         
    
     Table.AddColumn( ddate , "new date " ,each   
    let Mdate = [Sdate] , 
    change = 
    List.Distinct( 
    List.Select(  
     List.InsertRange( 
    List.Transform( 
     { Number.From([Sdate]) .. Number.From([End Date]) },
    (A)=> Date.StartOfMonth( Date.From(A) ) ),0,{ [Sdate]}  ),
          each Number.From(_) >= Number.From(Mdate) )) 
     in  change)

    I tried using ;

    let Mdate = [Sdate] , 
       Table.AddColumn( ddate , "new date " ,each
    List.Distinct( 
    List.Select(  
     List.InsertRange( 
    List.Transform( 
     { Number.From([Sdate]) .. Number.From([End Date]) },
    (A)=> Date.StartOfMonth( Date.From(A) ) ),0,{ [Sdate]}  ),
          each Number.From(_) >= Number.From(Mdate) )) 
       )

    but this didn't work, can someone help with information on why I had to use the variable in the first place and any general help

    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. [SOLVED] Power Query/Power Pivot Conditional Column creation & chart
    By mz_h in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 12-12-2020, 06:07 PM
  2. [SOLVED] 2 fields checker- Request for alternative option in Power Query or Power Pivot
    By Shareez Saleem in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 11-15-2020, 08:36 AM
  3. Replies: 10
    Last Post: 06-25-2020, 12:19 AM
  4. [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
  5. Replies: 4
    Last Post: 02-17-2020, 06:03 AM
  6. Excel Power Query Refresh or Access Query - 2nd Query Run is faster
    By Steveapa in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-03-2020, 10:16 AM
  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