Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Antmkjr
Helper V
Helper V

What other products

ProdID
A1
C1
D1
A2
E2
D3
E3
B4
D4

 

From the above data,  i need to create a report , with prod as filter ,

Eg if i select A, a table visual should show me , what other products have people who purchased A also bought.

So in this case expected output when i select A as prod filter :

C

D

E

 

If i select D, expected output :

A

C

E

B

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how is your desired outcome looks like, but please check the below picture and the attached pbix file.

I suggest having a disconnected slicer table like below.

 

 

Jihwan_Kim_1-1666621873124.png

 

 

Jihwan_Kim_0-1666621847919.png

 

 

ID measure: =
IF (
    HASONEVALUE ( Data[Prod] ),
    MAXX (
        FILTER (
            Data,
            Data[Prod] <> SELECTEDVALUE ( Slicer[Prod] )
                && Data[ID] IN DISTINCT ( Slicer[ID] )
        ),
        Data[ID]
    )
)

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


View solution in original post

4 REPLIES 4
CNENFRNL
Community Champion
Community Champion

For fun only, add one more rule to your original question,

when multiple products selected, show other products in the same purchase that contains all selected products. (eg. when A/C are selected together, only purchase 1 is qualified, then D shows)

 

Try to wrap your head around the measure, then your level of comprehension of DAX is beyond 99.9% of users.

_ = 
VAR __sel = COUNTROWS( ALLSELECTED( PROD[Prod] ) )
// IDs containing all selected Prods
VAR __id =
    CALCULATETABLE(
        FILTER(
            VALUES( SALES[ID] ),
            CALCULATE( DISTINCTCOUNT( SALES[Prod] ) ) = __sel
        ),
        ALLEXCEPT( SALES, PROD[Prod] )
    )
RETURN
    IF(
        ISEMPTY( SALES )
            && NOT ISEMPTY( CALCULATETABLE( SALES, __id, REMOVEFILTERS( PROD[Prod] ) ) ),
        ""
    )

CNENFRNL_0-1666648695953.gif

 


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Wow!Great!

Would you be so kind to add these also to the functionality:

IDProdCategoorySum of Amount
1ACloth40
1CWatch50
1DCosmetics60
2ACloth70
2EShoes80
3DCosmetics10
3EShoes20
4BElectronics30
4DCosmetics40
999BElectronics55
999CWatch35
999DCosmetics65
999EShoes75

 

Need to have Amount , And distinct count of ID to the table,

AnuTomy_2-1666687733706.png

Also need a category filter with the values in the table.(in this case when Prod A is selected , Category filter should show Watch, cosmetics, shoes)

AnuTomy_3-1666687839736.png

 

 

 

 

Jihwan_Kim
Super User
Super User

Hi,

I am not sure how is your desired outcome looks like, but please check the below picture and the attached pbix file.

I suggest having a disconnected slicer table like below.

 

 

Jihwan_Kim_1-1666621873124.png

 

 

Jihwan_Kim_0-1666621847919.png

 

 

ID measure: =
IF (
    HASONEVALUE ( Data[Prod] ),
    MAXX (
        FILTER (
            Data,
            Data[Prod] <> SELECTEDVALUE ( Slicer[Prod] )
                && Data[ID] IN DISTINCT ( Slicer[ID] )
        ),
        Data[ID]
    )
)

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


johnt75
Super User
Super User

I think you would need to create a separate table containing the product keys which is not connected to any tables. You could create that like

Slicer table = ALLNOBLANKROW('Table'[Product])

You could then create a measure like

Is visible in also bought =
VAR CurrentProduct =
    SELECTEDVALUE ( 'Table'[Product] )
VAR SlicerProduct =
    SELECTEDVALUE ( 'Slicer table'[Product] )
VAR BoughtInOrders =
    CALCULATETABLE (
        VALUES ( 'Table'[ID] ),
        TREATAS ( { SlicerProduct }, 'Table'[Product] )
    )
VAR OtherProducts =
    CALCULATETABLE ( VALUES ( 'Table'[Product] ), BoughtInOrders )
VAR Result =
    IF ( CurrentProduct IN EXCEPT ( OtherProducts, { SlicerProduct } ), 1 )
RETURN
    Result

and place that as a filter on the table visual, to only show when the value is 1.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors