Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

DAX query

Hi all,
 
This is the DAX query I have written.
 
Value = var m = (calculate(SUM('Table'[A]),FILTER('Table','Table'[B] = "0")))
 
But I still get an error, The syntax for ')' is incorrect. I am not sure what the problem is. Can I please know what is incorrect?
 
Any help is appreciated!
 
Thank you!
Megha
 
  • Hi Anonymous ,

     

    When using VAR, RETURN is required to return the final value/formula you want. You can write your formula as below

    Value =
    VAR m =
         CALCULATE ( SUM ( 'Table'[A] ), FILTER ( 'Table', 'Table'[B] = "0" ) ) 
    RETURN
        m

     

    or simply 

    Value =
    CALCULATE ( SUM ( 'Table'[A] ), FILTER ( 'Table', 'Table'[B] = "0" ) )

     

    By the way in case you are not aware 0 is different from "0" as the latter (in double quotes) is a text string.

1 Reply

  • Hi Anonymous ,

     

    When using VAR, RETURN is required to return the final value/formula you want. You can write your formula as below

    Value =
    VAR m =
         CALCULATE ( SUM ( 'Table'[A] ), FILTER ( 'Table', 'Table'[B] = "0" ) ) 
    RETURN
        m

     

    or simply 

    Value =
    CALCULATE ( SUM ( 'Table'[A] ), FILTER ( 'Table', 'Table'[B] = "0" ) )

     

    By the way in case you are not aware 0 is different from "0" as the latter (in double quotes) is a text string.