Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Contagem de produtos de clientes

Olá eu preciso contar quantos produtos são comprados pelos meus clientes.

 

Mas se ele comprar o produto a ,b,c deve contar como 1 unico produto. 

 

 

Exemplo: Prod : a, b,c,d,e,f

Quant_prod =3

 

Esquema: Tab_clientes, tab_prod

tab_compras = id_cliente, id_prod

  • Anonymous ,

    One way is where you create a group in power bi, Right click on the column and use the group option

     

    or create a new column

    if([Product] in {"a","b","c"}, "a", [Product])

     

     

    new measure  =

    var _tab = SELECTCOLUMNS('Table', "product_new", if('Table'[Product] in  {"a","b","c"}, "a"  , [Product])) return COUNTX(SUMMARIZE(_tab,[product_new]),[product_new])

     

2 Replies

  • Anonymous ,

    One way is where you create a group in power bi, Right click on the column and use the group option

     

    or create a new column

    if([Product] in {"a","b","c"}, "a", [Product])

     

     

    new measure  =

    var _tab = SELECTCOLUMNS('Table', "product_new", if('Table'[Product] in  {"a","b","c"}, "a"  , [Product])) return COUNTX(SUMMARIZE(_tab,[product_new]),[product_new])

     

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    You could add a calculated column to make these product a new group.

    new_product = if([product] in {"a","b","c"},"abc",[product])

    Then you could count the product group by the new_product column.

    count = calculate(distinctcount([new_product]),allexcept('table',[Tab_clientes]))

     

    Best Regards,

    Jay