0
votes

Calculate the sum of my sales from last week in Power BI (DAX).

Example: From Filter, If I have select a date that belongs to the 5th week of March then the result must be the sum of the sales of the 4th week of March.

I have tried this code but it doesn't return the desired result:

'THSalesp W-1 = CALCULATE(SUM(FACT_Production[THSales]); WEEKNUM(DIM_Time[CalDate])-(1))'
2

2 Answers

0
votes

Try something like,

THSalesp W-1 = CALCULATE(SUM(FACT_Production[THSales])
                        ,WEEKNUM(SELECTEDVALUE("YOUR FILTER DATE"))-1
0
votes

In order to solve the problem I was forced to modify my fact table and the time dimension by adding columns of concatenation of the year and the week number.