Forum Discussion

charlyrosero's avatar
charlyrosero
Frequent Visitor
7 years ago
Solved

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

  • 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

2 Replies

  • v-lili6-msft's avatar
    v-lili6-msft
    Icon for Community Support rankCommunity 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

    • charlyrosero's avatar
      charlyrosero
      Frequent Visitor

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