Forum Discussion

mdennis05's avatar
mdennis05
Regular Visitor
1 year ago
Solved

DAX Week to week difference to calculate an average usage

I am developing an inventory dashboard. Each week there will be a weekly count. I would like to calculation the average usage. I know I need to calculate the difference from each week's count for an item then average this. However, I am getting nowhere on it.

 

Last Week = CALCULATE(DISTINCTCOUNT('Count'[Product Name]), 'Calendar'[Week Num] = MAX('Calendar'[Week Num])-1)


Weekly Average = AVERAGEX(SUMMARIZE('Count','Count'[Quantity], "toAverage",[Last Week]),[Last Week])

This is returning 1 for values. which is correct then blank for others that should have a value.

My end goal is to use this as a minimum ordering level for 2 months. Multiplying the average weekly usage by 8.

  • Hi mdennis05 try v2 below

    Last Week v2 =

    VAR __week_filt= MAX('Calendar'[Week Num])-1

    CALCULATE(DISTINCTCOUNT('Count'[Product Name]), 'Calendar'[Week Num] = __week_filt)


    Weekly Average = AVERAGEX(SUMMARIZE('Count','Count'[Quantity], "toAverage",[Last Week]),[Last Week])

6 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi mdennis05,

    Thanks for reaching out to the Microsoft fabric community forum.

    It looks like you want to calculate the average of usage from your inventory dashboard. As bhanu_gautam and some_bih both responded to your query, please go through their responses and mark the helpful reply as solution.

     

    I would also take a moment to thank bhanu_gautam and some_bih, for actively participating in the community forum and for the solutions you’ve been sharing in the community forum. Your contributions make a real difference.

     

    If I misunderstand your needs or you still have problems on it, please feel free to let us know.  

    Best Regards,
    Hammad.
    Community Support Team

     

    If this post helps then please mark it as a solution, so that other members find it more quickly.

    Thank you.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi mdennis05,

      As we haven’t heard back from you, so just following up to our previous message. I'd like to confirm if you've successfully resolved this issue or if you need further help.

      If yes, you are welcome to share your workaround and mark it as a solution so that other users can benefit as well. If you find a reply particularly helpful to you, you can also mark it as a solution.


      If you still have any questions or need more support, please feel free to let us know. We are more than happy to continue to help you.
      Thank you for your patience and look forward to hearing from you.

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi mdennis05,

        I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution so that other community members can find it easily.


        Thank you.

  • some_bih's avatar
    some_bih
    Icon for Community Champion rankCommunity Champion

    Hi mdennis05 try v2 below

    Last Week v2 =

    VAR __week_filt= MAX('Calendar'[Week Num])-1

    CALCULATE(DISTINCTCOUNT('Count'[Product Name]), 'Calendar'[Week Num] = __week_filt)


    Weekly Average = AVERAGEX(SUMMARIZE('Count','Count'[Quantity], "toAverage",[Last Week]),[Last Week])

  • mdennis05 Try using

     

    Calculate the previous week's count:

    LastWeekCount =
    CALCULATE(
    SUM('Count'[Quantity]),
    'Calendar'[Week Num] = MAX('Calendar'[Week Num]) - 1
    )

     

    Calculate the difference from the previous week:

    DAX
    WeekDifference =
    SUM('Count'[Quantity]) - [LastWeekCount]

     

    Calculate the average of these differences:

    DAX
    AverageWeeklyUsage =
    AVERAGEX(
    SUMMARIZE(
    'Count',
    'Calendar'[Week Num],
    "WeeklyDiff", [WeekDifference]
    ),
    [WeeklyDiff]
    )

     

    Calculate the minimum ordering level for 2 months (8 weeks):

    MinOrderingLevel = [AverageWeeklyUsage] * 8