Forum Discussion

stefani_vileva's avatar
stefani_vileva
Resolver II
3 years ago
Solved

Measure wrongly summing column

Hello, I have three measures for summing up quantities, the first Prev. week is suming the quantity of the previous week, the second PrePrev. week is summing the quantity of the previous previous wee...
  • stefani_vileva's avatar
    3 years ago

    I solved the problem. It was something wrong with the calculation of the week number, so instead of the formula above, I used the following code:

    Previous year order (Kolli) = 
    
    VAR WEEK_NUM = WEEKNUM(TODAY(), 2) - 1
    VAR YEAR_WEEK = (YEAR(TODAY())-1)*100+WEEK_NUM
    VAR YEAR_WEEK_RANK = CALCULATE(MAX('Date'[Week rank]), FILTER(All('Date'), 'Date'[Year week]=YEAR_WEEK))
    
    VAR QUANTITY_PREVIOUS_YEAR_WEEK = CALCULATE(SUM(Lieferungs[KOLLI]), FILTER(ALL('Date'), 'Date'[Week rank]=YEAR_WEEK_RANK))
    
    RETURN
        QUANTITY_PREVIOUS_YEAR_WEEK