Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Measure Value convert to Text

Hi,

 

i have a trivial question but i dont can solve this issue :smileylol: .

So i have this Measure, a static string/text "2018", get the result and works fine. ;)

But now i want to replace the static stuff to dynamic measure "LastYear" and get this issue:

 

 

When i show both Measure "LastYear and ActualYear" in a card, table,.. then it show me the correct result "2018" & "2019"

 

I hope you can help me and thanks in advance

 

Kind regards,

Unknown

 

 

  • Anonymous's avatar
    Anonymous
    7 years ago

    Anonymous - 

    Try it with a variable instead of a measure.

    Variables can be loaded with a value and that value can then be used.

    Measures are evaluated at the point in which they are used. So in your measure, there is probably something else affecting it.

     

    General variable usage:

     

    Previous Year = 
    var my_variable = max('Date'[Year])
    return my_variable - 1

    Cheers!

    Nathan

  • AlB's avatar
    AlB
    7 years ago

    Hi Anonymous 

    It looks like you are using the simplified syntax for the filter parmeters in the CALCULATE where it is not allowed. 

    Instead of

    CALCULATE(SUM( ...); Table1[Geschäftsjahr] = [LastYear])

    try

    CALCULATE( SUM( ...);

                        FILTER( ALL(Table1[Gefächstjahr]); Table1[Geschäftsjahr] = [LastYear]) )

     

3 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Anonymous - 

    Try it with a variable instead of a measure.

    Variables can be loaded with a value and that value can then be used.

    Measures are evaluated at the point in which they are used. So in your measure, there is probably something else affecting it.

     

    General variable usage:

     

    Previous Year = 
    var my_variable = max('Date'[Year])
    return my_variable - 1

    Cheers!

    Nathan

    • AlB's avatar
      AlB
      Community Champion

      Hi Anonymous 

      It looks like you are using the simplified syntax for the filter parmeters in the CALCULATE where it is not allowed. 

      Instead of

      CALCULATE(SUM( ...); Table1[Geschäftsjahr] = [LastYear])

      try

      CALCULATE( SUM( ...);

                          FILTER( ALL(Table1[Gefächstjahr]); Table1[Geschäftsjahr] = [LastYear]) )

       

      • Anonymous's avatar
        Anonymous
        Not applicable

        AlB  & Anonymous  Thanks, both approach works. :) :)