Forum Discussion
punnas1
Helper II
5 years agoDax syntax error
I'm new to dax Pls help with error debug. I'm trying to calculate sum of sales increase 19 vs 20 by Product and customer. Positive diff = Var a = distinct (sales[product]) Var b = district ( sal...
AntrikshSharma
Community Champion
5 years agopunnas1 You are using DISTRICT instead of DISTINCT, the code that you have written won't work as both columns have a different data lienage and you will have to either SUM them differently then add or manually inject filters after Union which will be complex for you at your currentl level of DAX experience. For now I would suggest that you write something like this:
Positive diff =
VAR a =
DISTINCT ( sales[product] )
VAR b =
DISTINCT ( sales[customer] )
VAR Result =
SUMX ( a, MAX ( 0, [val diff 19vs20] ) )
+ SUMX ( b, MAX ( 0, [val diff 19vs20] ) )
RETURN
Result