Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
8 years ago

I need help

 

Hi, I need SUBTRACT the column [COD] line by line> Example> LINE2 - LINE1; LINE3 - LINE2; LINE4 - LINE3 ....

 

but column [COD] is MEASURE and i do not know how i make it.

 

7 Replies

  • Hi Anonymous,

     

    What is the formula for the COD.

     

    I also think you cant use Earlier to grab the previous information, but I need to know what COD is before giving a try to the final formula.

     

    Ninter

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Interkoubess this formula COD is  :

      COD = CALCULATE (min('CORRIDAS'[COD_IDENT_CORRI]);
      FILTER (
      'CORRIDAS';
      'CORRIDAS'[DTH_INIC_CORRI] < MIN ( 'PARADAS'[DTH_INIC_PARAD] )
      && 'CORRIDAS'[DTH_FIM_CORRI] > MIN ( 'PARADAS'[DTH_FIM_PARAD] )
      )
      )

  • Anonymous's avatar
    Anonymous
    Not applicable

    You could create a column for previous day/period COD and then another column which is difference of the 2. 

     

    =CALCULATE(SUM[COD], DATEADD(TableName[DateField],-1,day))

     

    OR

     

    You could get values using the previousday function. https://msdn.microsoft.com/en-us/query-bi/dax/previousday-function-dax

     

    OR

     

    If you dont know the last date you could calculate previous period using 

     

    Last=

    VAR LastPeriod= CALCULATE (MAX ( FactName[DimDateKey] ),

            FILTER (FactName, FactName[DimDateKey] <> ( FactName[DimDateKey] )))

    RETURN LastPeriod

    • Anonymous's avatar
      Anonymous
      Not applicable

       

      Anonymous But  COD is INT not DATE .

       

       

      I need FILTER DATE and DES_COMPT_PARAD  and CALCULATE  [COD]Line 2 - [COD]Line 1  ; [COD]Line 3 - [COD]Line 2  and etc

      • Anonymous's avatar
        Anonymous
        Not applicable

        Anonymous I know, that is why I am using it as a sum and not the date field.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Anonymous I just want to confirm how do you determine whats Line 1 and whats Line 2?