Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago

New Measures - Weekly Current Year, Weekly Last Year, YTD Weekly Current and YTD Weekly Last Year

Hi there,

 

I have a transaction list. It runs on daily basis. I have it summarized by week ending #. 

 

Something like this:

Ticket Number | Date | Amount | Week Ending #

 

It could have multiple transactions every day in the week. 

 

I am trying to create a few measures to capture:

 

Weekly Current Year Amount

Weekly Last Year Amount

YTD Weekly Current Year Amount

and YTD Weekly Last year Amount

 

I have tried a few coding... doesn't seem to work...

 

Please advise.

 

Jen

9 Replies

  • Anonymous there are tons of posts on time intelligence, did you searched and tried?

     

    Here is a link to few:

     

    https://radacad.com/basics-of-time-intelligence-in-dax-for-power-bi-year-to-date-quarter-to-date-month-to-date

     

    https://www.red-gate.com/simple-talk/sql/bi/creating-time-intelligence-functions-in-dax/

     

    I would 💖 Kudos 🙂 if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

    • Anonymous's avatar
      Anonymous
      Not applicable

      Those are informative posts. 

       

      My question is more on what to do with Weekly measures. The YTD, QTD or MTD work fine for me. Given WTD or week to date functions are not available in Power BI, I need further guidence.

       

      Thank you

       

      Jen

  • v-lionel-msft's avatar
    v-lionel-msft
    Icon for Community Support rankCommunity Support

    Hi Anonymous ,

     

    Do you want to create the following four measures?

    Please give example data for all used tables.

     

    Best regards,
    Lionel Chen

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

    • Anonymous's avatar
      Anonymous
      Not applicable

      • v-lionel-msft's avatar
        v-lionel-msft
        Icon for Community Support rankCommunity Support

        Hi Anonymous ,

         

        Maybe you can do like this:

        Weekly Current Year Amount = 
        CALCULATE(
            SUM(Sheet1[Amount]),
            FILTER(
                ALL(Sheet1),
                Sheet1[Year] = SELECTEDVALUE( Sheet1[Year]) && Sheet1[Week] = SELECTEDVALUE(Sheet1[Week])
            )
        )
        Weekly Last Year Amount = 
        CALCULATE(
            SUM(Sheet1[Amount]),
            FILTER(
                ALL(Sheet1),
                Sheet1[Year] = SELECTEDVALUE(Sheet1[Year]) - 1 && Sheet1[Week] = SELECTEDVALUE(Sheet1[Week])
            )
        )
        YTD Weekly Current Year Amount = 
        CALCULATE(
            SUM(Sheet1[Amount]),
            FILTER(
                ALLSELECTED(Sheet1),
                Sheet1[Year] = SELECTEDVALUE(Sheet1[Year]) && Sheet1[Week] <= SELECTEDVALUE(Sheet1[Week]) 
            )
        )
        YTD Weekly Last year Amount = 
        CALCULATE(
            SUM(Sheet1[Amount]),
            FILTER(
                ALLSELECTED(Sheet1),
                Sheet1[Year] = SELECTEDVALUE(Sheet1[Year])-1 && Sheet1[Week] <= SELECTEDVALUE(Sheet1[Week]) 
            )
        )

         

        Best regards,
        Lionel Chen

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