Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Multiple value division using dax

  • 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 _ kalyj

    If this post helps, then please considerAccept it as the solution to help the other members find it more quickly.

     

    Multiple value division using dax.pbix18 KB

2 Replies

  • Anonymous , This a measure

     

    Divide(Sum(Table[Total Price]), Sum(Table[Qty]) )

     

    You need use measure or aggregation with columns in a measure

  • 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 _ kalyj

    If this post helps, then please considerAccept it as the solution to help the other members find it more quickly.

     

    Multiple value division using dax.pbix18 KB