Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Bi-week Calculation

Hello everybody,

 

I need your help to make a calculate columns for my table. 

I have this kind of table, Where I want to add a new 2 columns :

 

Activities Dateactivityiduserid
08/02/2021actid1id1
15/02/2021actid2id1
17/02/2021actid3id1
11/02/2021actid4id2
23/02/2021actid5id3
24/02/2021actid6id1
25/02/2021actid7id1

 

the first column it will be the bi-week number and the second one the number of activity by user during each bi-week.

 

Activities Dateactivityiduseridbi-weekactivity by bi-week
08/02/2021actid1id1weeks 6-73
15/02/2021actid2id1weeks 6-73
17/02/2021actid3id1weeks 6-73
11/02/2021actid4id2weeks 6-71
23/02/2021actid5id3weeks 8-91
24/02/2021actid6id1weeks 8-92
25/02/2021actid7id1weeks 8-92

 

Thank you for your help.

 

Best,

  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi Anonymous ,

     

    Based on your description, you can create two columns as follows.

    bi-week = 

    var x1=WEEKNUM([Activities Date],2)-1

    var x2=IF((x1/2-INT(x1/2))>0,x1-1,x1)

    return

    "weeks"&" "&x2&"-"&x2+1
    activity by bi-week = CALCULATE(COUNTROWS('Test'),ALLEXCEPT(Test,Test[bi-week],Test[userid]))

    Result:

     

    Hope that's what you were looking for.

    Best Regards,

    Yuna

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

3 Replies

  • Anonymous , I am not clear on the logic you used for the last 2 columns in second table

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hello amitchandak, I want to claculate the total of activity maked by one users every two weeks.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    Based on your description, you can create two columns as follows.

    bi-week = 

    var x1=WEEKNUM([Activities Date],2)-1

    var x2=IF((x1/2-INT(x1/2))>0,x1-1,x1)

    return

    "weeks"&" "&x2&"-"&x2+1
    activity by bi-week = CALCULATE(COUNTROWS('Test'),ALLEXCEPT(Test,Test[bi-week],Test[userid]))

    Result:

     

    Hope that's what you were looking for.

    Best Regards,

    Yuna

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.