Forum Discussion
Multiple value division using dax
Can we divide two columns with multiple values in power bi ?? if yes, then please tell. I am trying to divide two columns with multiple values. the columns are total price and unit price ,I want to create a column which shows no. of quantity for each but by using divide it shows the error: A single value for column 'totalprice' in table 'Table' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count .
How can I find Quantity??
Hi Anonymous ,
In my understanding, you want to calculate the total price divided by the unit price to get the quantity.
Measure is an aggregation operation, which requires context in calculation. Unlike calculated column, which refers to the current row, it can be directly referenced.
I create a sample.
Here's my solution, create a measure.
Measure = VAR _T = ADDCOLUMNS ( 'Table', "Quantity", DIVIDE ( 'Table'[totalprice], 'Table'[unitprice] ) ) RETURN SUMX ( _T, [Quantity] )You can put customer column and the measure in a table visual to get the seperate quantity of each customer or put the measure in a card visual to get the total quantity.
I attach my sample below for reference.
Best Regards,
Community Support Team _ kalyjIf this post helps, then please considerAccept it as the solution to help the other members find it more quickly.
2 Replies
- amitchandakSuper User
Anonymous , This a measure
Divide(Sum(Table[Total Price]), Sum(Table[Qty]) )
You need use measure or aggregation with columns in a measure
- v-yanjiang-msftCommunity Support
Hi Anonymous ,
In my understanding, you want to calculate the total price divided by the unit price to get the quantity.
Measure is an aggregation operation, which requires context in calculation. Unlike calculated column, which refers to the current row, it can be directly referenced.
I create a sample.
Here's my solution, create a measure.
Measure = VAR _T = ADDCOLUMNS ( 'Table', "Quantity", DIVIDE ( 'Table'[totalprice], 'Table'[unitprice] ) ) RETURN SUMX ( _T, [Quantity] )You can put customer column and the measure in a table visual to get the seperate quantity of each customer or put the measure in a card visual to get the total quantity.
I attach my sample below for reference.
Best Regards,
Community Support Team _ kalyjIf this post helps, then please considerAccept it as the solution to help the other members find it more quickly.