Forum Discussion

ania_roh's avatar
ania_roh
Helper III
4 years ago
Solved

doubt with DAX expression

Hello. I´m learning Dax and there is one thing which I don´t understand. Could you help me to understand the reason of why the result of these expressions are like that? If I use for example this e...
  • Jihwan_Kim's avatar
    Jihwan_Kim
    4 years ago

    Hi,

    Inside ADDCOLUMNS,

    the first two examples are using the measure, [Sales Amount]

    the last example is using the expression, SUMX( Sales, Sales[Price] * Sales[Quantity] )

     

     

    Please try to use the below if you want to write an expression when creating a table.

     

    Categories Table =
    ADDCOLUMNS (
    SUMMARIZE ( 'Product', 'Product'[Category], 'Product'[Subcategory] ),
    "@sales", CALCULATE ( SUMX ( Sales, Sales[Price] * Sales[Quantity] ) )
    )

     

     

    Those two functions are different functions.

    Sometimes, ALL and SUMMARIZE do the same job, sometimes do not.

     

    My preference is writing like below. But it depends on the case.

     

    Categories Table =
    SUMMARIZECOLUMNS (
    'Product'[Category],
    'Product'[Subcategory],
    "@sales", SUMX ( Sales, Sales[Price] * Sales[Quantity] )
    )