Forum Discussion

OscarSuarez10's avatar
OscarSuarez10
Helper III
6 years ago

Payback problem

Hello I´m trying to use the following formula to get the payback, but when I got a problem when I use it, can you help me? 

The 'pruebas economicValues_global'[FLUJOCAJA ACUMULADO] is a measure what can i do?

 

8 Replies

  • AlB's avatar
    AlB
    Community Champion

    Hi OscarSuarez10 

    You might to change

    VAR Numerator_ = CALCULATE(DISTINCT(Table1[ACCUMULATED CASH FLOW]);Table1[YEAR] = Year_) 

    to 

    VAR Numerator_ = CALCULATE(DISTINCT(Table1[ACCUMULATED CASH FLOW]); FILTER( ALL(Table1[YEAR]),Table1[YEAR] = Year_) ) 

    The names are a bit different but you get the idea. 

     

    Please mark the question solved when done and consider giving kudos if posts are helpful.

    Cheers  Datanaut

    • OscarSuarez10's avatar
      OscarSuarez10
      Helper III

      Hello AlB  thanks for your help, I changed the script but I got the same mistake again: 

      A function 'CALCULATE' has been used in a True/False expression that is used as a table filter expression. This is not allowed.

  • Nathaniel_C's avatar
    Nathaniel_C
    Community Champion

    Hi OscarSuarez10 , AlB ,

    Is the issue that DISTINCT returns a one-column table that contains the distinct values from the specified column. In other words, duplicate values are removed and only unique values are returned. Maybe DISTINCTCOUNT ?

    Nathaniel

    • OscarSuarez10's avatar
      OscarSuarez10
      Helper III

      Hello Nathaniel_C  I changed it to DISTINTCOUNT and i got the following mistake: 

      column 'FLUCAJA ACUMULADO' in table 'pruebas economicValues_global' cannot be found or may not be used in this expression.

       

      And it´s because 'FLUCAJA ACUMULADO' is not a column is a Measure, what can i do?


      • Nathaniel_C's avatar
        Nathaniel_C
        Community Champion

        OscarSuarez10 , So tell us what you are trying to do in Numerator.  BTW if you use a measure, you don't reference the table.

        Nathaniel