Forum Discussion

rosscortb's avatar
rosscortb
Post Patron
7 years ago
Solved

Apply previous month to Difference from Filtered Value Quick Measure

Hi, I am trying to count the previous month headcount after filtering out the "babcock - weekly" in the Payroll Area column. I can get this on current month but where do I apply the previous month? Thanks Ross Count of Payroll Area difference from Babcock - Weekly 2 = VAR __BASELINE_VALUE = CALCULATE( COUNTA('DB Headcount'[Payroll Area]), 'DB Headcount'[Payroll Area] IN { "Babcock - Weekly" } ) VAR __MEASURE_VALUE = COUNTA('DB Headcount'[Payroll Area]) RETURN IF(NOT ISBLANK(__MEASURE_VALUE), __MEASURE_VALUE - __BASELINE_VALUE)
  • rosscortb

     

    I can't see your sample data, so maybe my answer is not correct.

     

    You can try below coding to see if you can count last month's amount.

     

    VAR maxdate= max('date')

    VAR lastmont=edate(maxdate,-1)

    CCOUNTROWS(FILTER('DB Headcount',date=lastmonth && 'DB Headcount'[Payroll Area] <> "Babcock - Weekly"))

3 Replies

  • Or can add I Previous Month to this, Measure = COUNTROWS(FILTER('DB Headcount','DB Headcount'[Payroll Area] <> "Babcock - Weekly"))
    • ryan_mayu's avatar
      ryan_mayu
      Super User

      rosscortb

       

      I can't see your sample data, so maybe my answer is not correct.

       

      You can try below coding to see if you can count last month's amount.

       

      VAR maxdate= max('date')

      VAR lastmont=edate(maxdate,-1)

      CCOUNTROWS(FILTER('DB Headcount',date=lastmonth && 'DB Headcount'[Payroll Area] <> "Babcock - Weekly"))

      • rosscortb's avatar
        rosscortb
        Post Patron

        Hello

         

        I managed to get this to work(sort of)

         

        Meausure 4 = COUNTROWS(FILTER('DB Headcount','DB Headcount'[Payroll Area] <> "Babcock - Weekly" && PREVIOUSMONTH('Month'[Date])))
         
        My figures started last April(I've no figures for this year yet just april - dec 2018) and the measure returns the value of number of rows minus april, so its not looking at the last month but at everything but the first month of my data which is april.