Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago

Add value to only one distinct date

I want to add a "1" in the beginning of each day and only once. 

rmd_date  I want to create this column
12-04-2023  0
12-04-2023  1
11-04-2023  0
11-04-2023  0
11-04-2023  1
10-04-2023  1
9-04-2023  0
9-04-2023  0
9-04-2023  1

 

7 Replies

  • DOLEARY85's avatar
    DOLEARY85
    Icon for Resident Rockstar rankResident Rockstar

    Hi, you could use a calculated column with DAX,

     

    i've assumed the 1 and 0 depends on whether you want a day adding or not if so:

     

    Column = if(VALUE('Table (4)'[Value])=1,DATEADD('Table (4)'[Date],1,DAY))
     

     

     
    If I answered your question, please mark my post as solution, Appreciate your Kudos 👍

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you. I have updated the question. Hope it makes more sense now 🙂

  • DOLEARY85's avatar
    DOLEARY85
    Icon for Resident Rockstar rankResident Rockstar

    Okay to do this:

     

    First i would sort the order of you date field ascending then add an index in power query.

     

    then create a column in DAX:

     

    Column 2 =
    IF (CALCULATE (COUNTROWS ('Table (4)'),FILTER (ALLEXCEPT ( 'Table (4)', 'Table (4)'[Date] ),'Table (4)'[Index] <= EARLIER ('Table (4)'[Index] )))> 1, 0, 1)
     

    If I answered your question, please mark my post as solution, Appreciate your Kudos 👍

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you for your resposse. It however doesn't seem to work...
      My line:

      IF( CALCULATE( COUNTROWS( MG_casing_record, FILTER( ALLEXCEPT (MG_casing_record, MG_casing_record[rmd_date]), MG_casing_record[id] <= EARLIER (MG_casing_record[id]))) > 1, 0, 1))

      It gives me this warning: "Too many arguments were passed to the COUNTROWS function. The maximum argument count for the function is 1."
      • DOLEARY85's avatar
        DOLEARY85
        Icon for Resident Rockstar rankResident Rockstar

        Hmmm okay, try changing the COUNTROWS  to COUNT