Forum Discussion

cyncyn_98's avatar
cyncyn_98
Frequent Visitor
4 years ago
Solved

Dax Measure : Column Previous Values

Hello everyone, 

 

I'm having a bit of trouble formulating the right dax measure. I have created a matrix table, that will show data based on a week ending date selected. And within the matrix table, I want to have columns that will show previous week's values. 

I have used the dax measure below, but I get a column with totals, instead of the total by Branch Type. The total value is correct, I just need the column to show the right values by branch type. 

 

Prev Hours = CALCULATE(
    sum('Branch Flash Report'[TempHrs]),
    FILTER(ALL('Branch Flash Report'),'Branch Flash Report'[WeekID] = MAX('Branch Flash Report'[WeekID])-1))

 

Thank you!

  • cyncyn_98 

    Please try it this way:

    Prev Hours =
    VAR __WEEKID =
        MAX ( 'Branch Flash Report'[WeekID] )
    RETURN
        CALCULATE (
            SUM ( 'Branch Flash Report'[TempHrs] ),
            'Branch Flash Report'[WeekID] = __WEEKID - 1,
            REMOVEFILTERS ( 'Branch Flash Report'[WeekID] )
        )
    

2 Replies

  • cyncyn_98 

    Please try it this way:

    Prev Hours =
    VAR __WEEKID =
        MAX ( 'Branch Flash Report'[WeekID] )
    RETURN
        CALCULATE (
            SUM ( 'Branch Flash Report'[TempHrs] ),
            'Branch Flash Report'[WeekID] = __WEEKID - 1,
            REMOVEFILTERS ( 'Branch Flash Report'[WeekID] )
        )