Forum Discussion

as3znaus's avatar
as3znaus
Icon for Helper I rankHelper I
9 years ago

Estimation from past month

Hi everyone!

 

Hope someone can help me with this. 

 

I have the following data in an excel spreadsheet.

 

 

CodeDirect costsStaff  costs BillingDateReport Date

 

P14.00010-4.0800oct.-16sep-16
P14.00010-5100nov.-16sep-16
P14.00010-5100dic.-16sept-16

 

As you can see, I have a Staff cost of 4.080 for October on my September Report (this number is an estimation).

 

 

The next month I will have the real cost for October, so I need a DAX function to compare these values.

 

1_Estimation M-1 for month M 

 

I need a formula to find the number that corresponds to date M (oct-16) and report date M-1 (sep-16), in this case 4.080.

 

2_Actual cost

 

I already got this meassure.

 

3_Difference between value

 

I already got this meassure.

 

 

 

Thanks a bunch!

 

4 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi as3znaus,

     

    You can try to use belwo formula to get previous month's value:


    Total cost of Previous Month=
    var currCode= LASTNOBLANK(Table[Code],[Code])

    Return
    IF(Month(MAX[Date]))>1,

    SUMX(FILTER(ALL(Table),[Code]= currCode && Month([Date])=Month(MAX([Date]))-1),[Staff  costs]),

    SUMX(FILTER(ALL(Table),[Code]= currCode && Year([Date])=Year(MAX([Date]))-1&&Month([Date])=12),[Staff  costs]))

     

    Regards,

    Xiaoxin Sheng

    • as3znaus's avatar
      as3znaus
      Icon for Helper I rankHelper I

      Hi Anonymous,

       

      I have tried your formula but I can't make it work...these are my actual column names.

       

      Code = Código

       

      Table = DatosCostes

       

      StaffCosts = CostePersonal

       

      Date=Fecha

       

      ReportDate= Fecha Report

       

      I changed them and I get the following error:

       

      http://jmp.sh/79eEjfB

       

       

       Thanks!

       

       

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi as3znaus,

         

        It seems like you have miss the "=" charater.(my formula is a measure.)

         

        In addition, you can try to use english character to name the variable.

         

        Regards,

        Xiaoxin Sheng