Forum Discussion

Bruno_Soares_25's avatar
Bruno_Soares_25
Frequent Visitor
2 years ago
Solved

Calcuated Measure Sum per row duplicating

I've got this measure and the outcome is like 50/50 the sum is correct but the drill down by dimension is duplicating the total value in each row 

 

% teste =
VAR Startperiod =
PREVIOUSDAY(FIRSTDATE(DATEADD(DATA[Date],-1*[C. Days of Current Period],DAY)))
VAR Endperiod =
PREVIOUSDAY(LASTDATE(DATEADD(DATA[Date],-1*[C. Days of Current Period],DAY)))
VAR PreviousCost =
CALCULATE(
    SUMX(
        FILTER(
            ALL(DATA),
            DATA[Date] >= Startperiod && DATA[Date] <= Endperiod
        ),
        DATA[Total Cost]
    )
)

RETURN PreviousCost

Also tried this one

% teste = 
VAR Startperiod =
PREVIOUSDAY(FIRSTDATE(DATEADD(DATA[Date],-1*[C. Days of Current Period],DAY)))
VAR Endperiod =
PREVIOUSDAY(LASTDATE(DATEADD(DATA[Date],-1*[C. Days of Current Period],DAY)))
VAR PreviousCost =
CALCULATE([SUM Total Cost],DATESBETWEEN(DATA[Date],Startperiod,Endperiod),ALL(DATA))
RETURN PreviousCost

 


So the out come should be the 1st option but its the 2nd one

  

 

I've tried to do the same calculations by creating measures instead of variables but the outcome is the same.

Thanks!

1 Reply