Forum Discussion

shamsMQ's avatar
shamsMQ
New Member
1 year ago

Week on Week change by Calculation Group

I am using this code to determine the week-on-week change in the calculation group. The requirement is similar to any other week-on-week change visualization function only I want to compare last week's closing value with this week's closing value. 
 
Current | Previous Week =
Var _CurrentWeek=ROUNDUP(CALCULATE(SELECTEDMEASURE(),LASTDATE(Clubbed_Data_Raw[Date])),0)
VAR_PreviousWeek=ROUNDUP(CALCULATE(SELECTEDMEASURE(),Clubbed_Data_Raw[Week]=max(Clubbed_Data_Raw[Week])-1,Clubbed_Data_Raw[Date]=MAX(Clubbed_Data_Raw[Date]),Clubbed_Data_Raw[Year]=MAX(Clubbed_Data_Raw[Year])),0)
RETURN
FORMAT(_CurrentWeek,"#,###")&" | "&FORMAT(_PreviousWeek,"#,###")
 
But executing this code showing me blank value in the PreviousWeek column in the matrice. Need help on this. 

2 Replies

  • Shahid12523's avatar
    Shahid12523
    Community Champion

    Your PreviousWeek is blank because filter conditions weren’t applied correctly.
    Fix with FILTER(ALL()) instead of direct column conditions:

     

    VAR _PreviousWeek =
    CALCULATE (
    SELECTEDMEASURE(),
    FILTER (
    ALL ( Clubbed_Data_Raw ),
    Clubbed_Data_Raw[Week] = MAX(Clubbed_Data_Raw[Week]) - 1 &&
    Clubbed_Data_Raw[Year] = MAX(Clubbed_Data_Raw[Year])
    )
    )