+ Reply to Thread
Results 1 to 5 of 5

Power Query: Identify 1st Occurrence of Value

  1. #1
    Registered User
    Join Date
    04-09-2014
    Location
    USA
    MS-Off Ver
    Excel 2016
    Posts
    18

    Power Query: Identify 1st Occurrence of Value

    Is there a way to identify the 1st occurrence of a value in a new column in Power Query with respect to "date"? For example,

    Date Value Unique
    6/10/16 a 1
    6/10/16 b 1
    6/10/16 c 1
    6/10/16 c 0
    6/10/16 a 0
    6/11/16 a 1

    I have been able to create a new column that gives a count of the times the value is duplicated. But I can't get quite what I need.

  2. #2
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Power Query: Identify 1st Occurrence of Value

    Hi,

    Can you sort on the first two columns, or do you need to preserve the current order of rows?
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  3. #3
    Registered User
    Join Date
    04-09-2014
    Location
    USA
    MS-Off Ver
    Excel 2016
    Posts
    18

    Re: Power Query: Identify 1st Occurrence of Value

    I believe sorting on those rows will be fine. The pivot table I'll eventually be using will group by date anyways. I can always try whatever you're thinking and see if it'll work out! Thanks!

  4. #4
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Power Query: Identify 1st Occurrence of Value

    Here are the steps you will require:
    1. Sort on date.
    2. Sort on value.
    3. Add an index column, then rename this step Sorted.
    4. Add a custom column called Unique, using the following formula:

    =if [Index]>0 then if Sorted{[Index] - 1}[Date] = [Date] and Sorted{[Index] - 1}[Value] = [Value] then 0 else 1 else 1

    You may then remove the Index column if you wish.
    Last edited by xlnitwit; 07-13-2016 at 05:05 PM. Reason: Correct step name

  5. #5
    Registered User
    Join Date
    04-09-2014
    Location
    USA
    MS-Off Ver
    Excel 2016
    Posts
    18

    Re: Power Query: Identify 1st Occurrence of Value

    Oh, how clever! I'll test this out! Thanks!

    Edit: Works wonderfully! Thanks so much!
    Last edited by kimbekaw; 07-14-2016 at 12:00 AM.

+ 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. [SOLVED] power query
    By juanda92 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-12-2016, 08:56 AM
  2. Power Query setup
    By chadjh in forum Excel - New Users/Basics
    Replies: 0
    Last Post: 05-05-2016, 11:02 PM
  3. VBA and Power Query
    By Brawnystaff in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 05-16-2015, 05:10 AM
  4. [SOLVED] Identify First Occurrence of a Purchase
    By clockspring in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-01-2014, 02:21 PM
  5. power point query
    By jrmehta in forum Excel General
    Replies: 1
    Last Post: 10-11-2010, 01:58 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