Forum Discussion

LilMurph's avatar
LilMurph
Frequent Visitor
4 years ago
Solved

Check if a value appears earlier in a column

Hi All

I have a table where one column specifies the week as 1, 2, 3 etc. Another column specifies a job by specific code i.e. ABC-123, ABC-578, CCA-246 etc. 

I want to create a new column which states that a job is new if the code does not occur in the first week. Does anyone have any advice on how to do this as I am drawing a blank.

Thanks

LilMurph

  • LilMurph , first week or last week

     

    A new column =

    var _cnt = countx(filter(Table, [Job] =earlier([Job]) && [Week] =1 ), [Job])

    return

    if(isblank(_cnt), "New", "Old")

     

    based on last week

     

    A new column =

    var _cnt = countx(filter(Table, [Job] =earlier([Job]) && [Week] =earlier([Week])  -1 ), [Job])

    return

    if(isblank(_cnt), "New", "Old")

2 Replies

  • LilMurph , first week or last week

     

    A new column =

    var _cnt = countx(filter(Table, [Job] =earlier([Job]) && [Week] =1 ), [Job])

    return

    if(isblank(_cnt), "New", "Old")

     

    based on last week

     

    A new column =

    var _cnt = countx(filter(Table, [Job] =earlier([Job]) && [Week] =earlier([Week])  -1 ), [Job])

    return

    if(isblank(_cnt), "New", "Old")

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi LilMurph ,

     

    May I ask if your problem has been solved? Did amitchandak's post above help you? If any of the posts are helpful, then please consider accepting it as a solution to help other members find it faster. Many thanks!

     

    If this doesn't work for you, would you mind providing some data that does not contain private information?

    It makes it easier to give you a solution.

    1. Sample (dummy dataset) data as text, use the table tool in the editing bar
    2. Expected output from sample data
    3. Explanation in words of how to get from 1. to 2.

    How to provide sample data in the Power BI Forum

    How to Get Your Question Answered Quickly

     

    Best Regards,
    Gao

    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

    How to get your questions answered quickly -- How to provide sample data