'How to calculate weekly sales velocity?

I have a table that lists a series of dates and a sales amount made on each date. So against each date, I would like to create two additional columns

a)A current week sales column that calculates the sum of all sales made in the week of the concerned date. b)A previous week sales column that calculates the sum of all sales made in the previous week of the concerned date.

I would then divide column a/b to get a ratio of the sales i.e weekly sales velocity. I would like to know what relevant DAX queries in Power BI, I will need to calculate the ratio



Solution 1:[1]

This can be accomplished using 4 calculated columns in Power BI:

Week = Sales[Date] - WEEKDAY(Sales[Date],2) + 1

Weekly Sales = CALCULATE(SUM(Sales[Sales]),ALLEXCEPT(Sales,Sales[Week]))

Previous Week = Sales[Date] - WEEKDAY(Sales[Date],2) + 1 -7

Previous Weekly Sales = LOOKUPVALUE(Sales[Weekly Sales],Sales[Week],Sales[Previous Week])

Here's a screenshot of the results

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Strictly Funk