Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago

VAR SYNTAX DAX , Please Help!

 

Hi Experts,

I am creating a measure using var. The highlighted var _cash is not picking up in my calculation.  I noticed that during calculation var _cash is being ignored.  Can you anyone check whether DAX is correct.

 

Thank you

7 Replies

  • I don't see where you're using __Cash. DAX will lazily ignore a variable if you never refer to it.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Alexis,

       

      I dont know how to refer var _Cash, Can you help in that.

       

      Many thanks.

      • AlexisOlson's avatar
        AlexisOlson
        Icon for Super User rankSuper User

        What do you want to do with that variable? If you don't want to use it, why is it defined?

  • Anonymous's avatar
    Anonymous
    Not applicable

    My Requirement is:

    If Fin_Level2= “Deposits and Current Account” than Sum of market_value_in_usd per Customer_No for latest BusinessDate and create a band.

     

    The banding as follows

     

    • AlexisOlson's avatar
      AlexisOlson
      Icon for Super User rankSuper User

      That doesn't really answer my question.

       

      You've defined __Cash as a table variable (like a temp table). That table doesn't affect the result of your calculation unless you use it somehow. It seems like maybe you want to use it as a filter but it isn't clear to me how that filter is supposed to affect the rest of the code.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi  Anonymous ,

    Var is a variable, which is equivalent to storing the result of an expression. When you use it, the result will be released and passed to other measurement expressions as a parameter.

    In your formula, although you use Var _Cash in Dax, you just store the result and don’t use it in the next formula, this caused Var _Cash to be ignored in the calculation process, and did not affect the formation of the final result.

    And your Var _CashbyCustomer is used in the following formula, so Var _CashbyCustomer is not ignored in the calculation

     

    Can you describe where Var _Cash is used or what specific role it plays in the formula.

    This is the usage and explanation of Var:

    https://docs.microsoft.com/en-us/dax/var-dax

     

    Best Regards,

    Liu Yang

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.