0
votes

I have a fact table with columns as Quantity, Unit Price, etc. I am trying to calculate the revenue with the SUMX formula but I am getting the same value for all the records. And due to this I am also getting a dependency error in other column. Here is the code:

SUMX(
    '''Sales Details$''',
    '''Sales Details$'''[Quantity]*'''Sales Details$'''[Unit Price]
)

enter image description here

This table has been imported from SSMS as it is, into the tabular model analysis service in VS2019. I wish to understand few things here-

  1. Why we have to provide a table inside of 3-quotes? The DAX bar is not taking the table without specifying them under 3-quotes.
  2. SUMX shouldn't evaluate the same value for all the records. But it is doing here for an unknown reason.
  3. If I try to replace the [Unit Price] with [Unit Cost] in the upper code then I am getting a dependency error in the new column. As far as I know, I am not using a CALCULATE function which will generate circular dependency and SUMX doesn't puts the filter on columns, [Quantity] here.
1

1 Answers

0
votes
  1. I think it is because the table name has spaces. When a table name has spaces or not allowed characters it goes between two single quotes: ""

  2. If I'm not wrong (I'm quite new with DAX too), SUMX is like sumproduct in Excel. It does the unit price * quantity per row and then sums up all the rows, breaking the row context. If you want to calculate the amount per row, just do price * quantity, without SUMX.

  3. I don't know, sorry.