Forum Discussion

jonbox's avatar
jonbox
Icon for Helper II rankHelper II
4 years ago
Solved

Measure to compared expected with actual

Hi,

 

I'm trying to create a measure to count the number of projects that went over their EXPECTED TOTAL SPEND by doing the following

 

Taking Expected total spend (this stays the same regardless of the month e.g. upgrade project in the below table isn't 8000, it's 2000 but the data just shows it at 2000 per month). Compare the sum of total spend over all months of the project, e.g. upgrade total spend is 300 + 600 + 400 + 800 = 2100 which is OVER the expected total spend of 2000.

 

Is there a measure that allows me to do this for each project? so that i can count the number over expected spend and number below?

 

ProjectNameExpected TOTAL SpendMonthTotal Spent
Upgrade20001300
Upgrade20002600
Upgrade20003400
Upgrade20004800
Expansion15001700
Expansion15002700
Expansion1500350
Refresh300011000
Refresh300022500
  • Num overbudget = 
    var summaryTable = ADDCOLUMNS( SUMMARIZE( 
       FILTER( 'Actual Spend + Firm',  'Actual Spend + Firm'[ProjectStatus] = "Closed"),
       'Actual Spend + Firm'[ProjectName]), "@val", [Spend difference]
    )
    return COUNTROWS( FILTER( summaryTable, [@val] < 0) )

    I think that'll do it

5 Replies

  • If you create a measure to calculate the difference, like

    Spend difference =
    var expectedSpend = MAX('Table'[Expected total spend])
    var totalSpent = SUM('Table'[Total Spent])
    return expectedSpend - totalSpent

    then you could create a couple of measures to show the number over and under budget, e.g.

    Num overbudget =
    var summaryTable = ADDCOLUMNS( SUMMARIZE( 'Table'[Project]), "@val", [Spend difference])
    return COUNTROWS( FILTER( summaryTable, [@val] < 0) )
    • jonbox's avatar
      jonbox
      Icon for Helper II rankHelper II

      Hi Johnt,

       

      Do you know how i can resolve the below error? 

      Num overbudget = 
      var summaryTable = ADDCOLUMNS( SUMMARIZE( 'Actual Spend + Firm' [ProjectName]), "@val", [Spend difference])
      return COUNTROWS( FILTER( summaryTable, [@val] < 0) )

       

       

      • johnt75's avatar
        johnt75
        Icon for Super User rankSuper User

        My mistake, forgot to include the table as the first parameter to SUMMARIZE

        Num overbudget = 
        var summaryTable = ADDCOLUMNS( SUMMARIZE( 'Actual Spend + Firm',  'Actual Spend + Firm'[ProjectName]), "@val", [Spend difference])
        return COUNTROWS( FILTER( summaryTable, [@val] < 0) )