Forum Discussion

ton-v's avatar
ton-v
Frequent Visitor
6 years ago
Solved

MTD based on week number problems

Hello everyone,

 

juste before i stard, i searched before i post this and i could not find the same problem as me.

 

i am comparing each week the evolution of the turnover, and then i compare it to the budget. 

 

Also i compare the actual MTD values.

my expression:

 

MTD:=CALCULATE([sales];DATESMTD(Sales[Date]))

 

It is working fine alone, but when i am comparing by week it's not working well because some weeks on based on two different month. My formula should take the last date of previous month when there is two month in a same week.

 

Exemple :

 

You can see on my example that for the week 4, the mtd value is for march but it should be februar.

 

I need a mtd value where it always take the last day of previous month when there are two different month in a week.

 

I hope you can help me.

 

Thank you in advance

 

 

 

 

  • ton-v's avatar
    ton-v
    6 years ago

    Hello,

     

    No it doesn't work ufortunately.

     

    Hopefully i resolved my problems by myself Here is the solution if people have the same issue.

     

    (1)calculate the first day of the week using the function "FIRSTDATE"

     

    (2)Then you calcultate the last day of the week  (1) + 6 

     

    (3) You use a if function to now if the month number of 1 and 2 are equal, if month are equal you can use the calculated lastday (2), if not you have to find the lastday of month (1) with this formula DATE(YEAR((1));MONTH((1)+1;1)-1.

     

    Finally you calculate the expression and for the filter you take datesbetween( firstdate(1);Lastdate(3)

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi ton-v ,

     

    How about using FILTER() function and MonthNo to filter out specified month?

     

    Best Regards,

    Jay

    Community Support Team _ Jay Wang

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

    • ton-v's avatar
      ton-v
      Frequent Visitor

      Hello,

       

      No it doesn't work ufortunately.

       

      Hopefully i resolved my problems by myself Here is the solution if people have the same issue.

       

      (1)calculate the first day of the week using the function "FIRSTDATE"

       

      (2)Then you calcultate the last day of the week  (1) + 6 

       

      (3) You use a if function to now if the month number of 1 and 2 are equal, if month are equal you can use the calculated lastday (2), if not you have to find the lastday of month (1) with this formula DATE(YEAR((1));MONTH((1)+1;1)-1.

       

      Finally you calculate the expression and for the filter you take datesbetween( firstdate(1);Lastdate(3)