Forum Discussion

peter_mx5's avatar
peter_mx5
New Member
2 years ago
Solved

Breaking down count measure in table visual

Hello, I have the following table "order_details_ss" (filtered for product_id 14): Assuming a slicer filters for product id = 162. My goal is to create a measure that counts how often a produ...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi peter_mx5 ,

     

    Thanks for the reply from lbendlin .

     

    Please try:

     

    Create a disconnected table:

    product_id

    158

    159

    162

    200

    2345

    1234

    123

    1

    88

     

    Drag the product id of the new table to the slicer:

     

    Create a measure:

    times bought together =
    VAR_curProduct=
         SELECTEDVALUE ( 'Pid'[product_id] )
    VAR_orderid=
         CALCULATE (
             MAX ( 'order_details_ss'[order_id] ),
             'order_details_ss'[product_id] = _curProduct
         )
    RETURN
         IF (
             MAX ( 'order_details_ss'[order_id] ) = _orderid
                 && MAX ( 'order_details_ss'[product_id] ) <> _curProduct,
             CALCULATE (
                 DISTINCTCOUNT ( order_details_ss[product_id] ),
                 ALLSELECTED ( 'Pid'[product_id] )
             ),
             BLANK()
         )

     

    Set the filter condition in the Filter pane to measure not blank.

     

    The table on the left is the original table. When 162 is selected, the table on the right displays data with the same order_id as 162.

     

    pbix file is attached.

     

    If you have any further questions please feel free to contact me.

     

    Best Regards,
    Yang
    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
    If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!