Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Create a variable in PowerBI with a filter

Hello Wonderful People

Please can someone point out the error in my syntax because PB error message for syntax is useless (or me?).  Thank you in advance.

test =
Var test =
CALCULATE(
SUM('Payment Report Template'[Payment Amount]),
FILTER('Payment Report Template','Payment Report Template'[Payment Type]="Practical Completion")
)
RETURN
  • Hi Anonymous 

     

    After Retun need to specify variable or a calculation you want to return
    check the below measure

    test =

    Var test =

    CALCULATE(

    SUM('Payment Report Template'[Payment Amount]),

    FILTER('Payment Report Template','Payment Report Template'[Payment Type]="Practical Completion")

    )

    RETURN test

    If this post helps, then please consider Accept it as the solution, Appreciate your Kudos!!

5 Replies

  • Jayee's avatar
    Jayee
    Responsive Resident

    Hi Anonymous 

     

    After Retun need to specify variable or a calculation you want to return
    check the below measure

    test =

    Var test =

    CALCULATE(

    SUM('Payment Report Template'[Payment Amount]),

    FILTER('Payment Report Template','Payment Report Template'[Payment Type]="Practical Completion")

    )

    RETURN test

    If this post helps, then please consider Accept it as the solution, Appreciate your Kudos!!

    • Anonymous's avatar
      Anonymous
      Not applicable

      Another question:

      I am trying to create a variable which contains multiple variables but the syntax contains errors that I can't tell:

      GFA_test =
      VAR pc_as20_test =
          CALCULATE(DISTINCTCOUNT('Weekly Report Template'[D_Code]),FILTER('Weekly Report Template', 'Weekly Report Template'[Application Stage] =" 20 Funding Agreement Signed"))

      VAR pc_as21_test =
          CALCULATE(DISTINCTCOUNT('Weekly Report Template'[D_Code]),FILTER('Weekly Report Template', 'Weekly Report Template'[Application Stage] =" 21 On Site Monitoring"))

      VAR pc_as22_test =
          CALCULATE(DISTINCTCOUNT('Weekly Report Template'[D_Code]),FILTER('Weekly Report Template', 'Weekly Report Template'[Application Stage] ="22 Practical Completion - Retention Period (12m)"))

      VAR pc_as23_test =
      CALCULATE(DISTINCTCOUNT('Weekly Report Template'[D_Code]),FILTER('Weekly Report Template','Weekly Report Template'[Application Stage] ="23 Retention Payment - Application Closed"))







      • Jayee's avatar
        Jayee
        Responsive Resident

        One question per ticket please. If you need to extend your request then please raise a new ticket.

         

        You will get a quicker response and each volunteer solver will get the kudos they deserve.

         

        Thank you ! 

  • Anonymous's avatar
    Anonymous
    Not applicable

    Thank you for your quick response!  The syntax is now working.