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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
charlyrosero
Frequent Visitor

DAX Summarize Combinations Products

hi, 

thank you for this post, really helped so much

https://community.powerbi.com/t5/Desktop/Sum-customers-by-product-combination-buyed-a-b-a-c-b-c-or-a...

but, right now i have a discussion because in the blend there are cases where for each row the values are repeated but inverted. for example 

 

Row   -  Value

A      -     5

B      -     6

A,B   -     2     *

B,A   -     1     *

 

mix.png

 

this is my formula

 

Resumen =
var temp= SUMMARIZE(
            BODEGA
            ,BODEGA[NIT]
            ,BODEGA[PRIMERNIVEL]
            ,"2_NIVEL", CONCATENATEX(
                            FILTER(
                                SUMMARIZE(BODEGA,[NIT],BODEGA[SEGUNDONIVEL])
                                ,BODEGA[NIT]=EARLIER(BODEGA[NIT])
                            )
                            ,[SEGUNDONIVEL]&","
                        )           
            ,"3_NIVEL", CONCATENATEX(
                            FILTER(
                                SUMMARIZE(BODEGA,[NIT],BODEGA[TERCERNIVEL])
                                ,BODEGA[NIT]=EARLIER(BODEGA[NIT])
                            )
                            ,[TERCERNIVEL]&","
                        )            
            )
return
SUMMARIZE(
    temp,
    BODEGA[PRIMERNIVEL],    
    [2_NIVEL],
    [3_NIVEL],
    "Number",DISTINCTCOUNT(BODEGA[NIT]),
    "Saldo",SUM(BODEGA[SALDO])
)

 

thank you for your help

1 ACCEPTED SOLUTION
v-lili6-msft
Community Support
Community Support

hi, @charlyrosero 

For CONCATENATEX Function, you could add an order conditional in it.

CONCATENATEX (
   <table>, <expression>, [<delimiter>], [<OrderBy_Expression1>], [<Order>] …
) 

https://dax.guide/concatenatex/

If not your case, please share your sample pbix file and expected output.

 

Best Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-lili6-msft
Community Support
Community Support

hi, @charlyrosero 

For CONCATENATEX Function, you could add an order conditional in it.

CONCATENATEX (
   <table>, <expression>, [<delimiter>], [<OrderBy_Expression1>], [<Order>] …
) 

https://dax.guide/concatenatex/

If not your case, please share your sample pbix file and expected output.

 

Best Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-lili6-msft  thank you so much, the solution was add the column in order by expression and indicate the order.  

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.