Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Compare 2 weeks in data table using 2 slicers

Hi all,   I am creating a HR report and one of the items I have been asked to implement is to have 2 slicers where management can compare the count of each job position, and calculate the variance ...
  • amitchandak's avatar
    amitchandak
    5 years ago

    Anonymous , Assume you have an independent date table and you want to use a period as a filter on Fact from week table, which is sortable (subtract -1)

    //Period or any column from week table is selected on slicer

     

    Try like this

     

    This Week =
    var _max1 = maxx(allselected('Date'), 'Date'[Week Rank])
    var _max = maxx(filter(all('Date'),'Date'[Week Rank] =_max), 'Date'[Period]) //Period we want to use in fact
    return
    CALCULATE(sum('order'[Qty]), FILTER('order', 'order'[Period]=_Max ))


    Last Week =
    var _max1 = maxx(allselected('Date'), 'Date'[Week Rank])-1
    var _max = maxx(filter(all('Date'),'Date'[Week Rank] =_max), 'Date'[Period]) //Period we want to use in fact
    return
    CALCULATE(sum('order'[Qty]), FILTER('order', 'order'[Period]=_Max ))