Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Calculating DISTINTCOUNT within Table

Hi all,

 

I have been struggling with a measure/ or logic that I hope some of you can help me with. I have a snapshot of my data set below:

Product KeyCustomer keyDate KeyLine itemValuePrice point 
10033330. juni 2021Units2Low 
11033330. juni 2021Units3Low 
12133330. juni 2021Units0  
13344430. juni 2021Units0Medium 
14644430. juni 2021Units0High 
10055530. juni 2021Units0Low 
16133329. juni 2021Units2High 
17755529. juni 2021Units2Low 
19555529. juni 2021Units2Low 
11033329. juni 2021Units2Low 
10033329. juni 2021Units2Best 

 

I'm trying to figure out how many unique customers have purchased either 0,1,2,3, or 4 of the price points. So, for example, if customer 166 purchased a low and best product, he should get a 2

 

So I have tried to create a measure that calculates unique local customers based on their unique price point. An example of the measure logic is below:

 

# of 1 PP POS =

CALCULATE (

    DISTINCTCOUNT ( Financials[Local Customer Key] ),

    Financials[Value] > 0,

    FILTER (

        Financials,

       CALCULATE (

            DISTINCTCOUNT ( Financials[Price Point] ),

            Financials[Value]>0,

            Financials[Price Point] <> BLANK ()

        ) = 1

    )

)

 

However, this does not return what is desired, which I presume is due to the difficulties in having a measure working with an if statement (Distinctount = 1)

 

It's my hope in the end to get a visual like the one below

 

 

Any ideas or advice is well received.

 

I really appreciate any help you can provide.

3 Replies

  • Anonymous , You need to create a measure then you need to create a bucket and use that

     

     

    measure =

    CALCULATE (

    DISTINCTCOUNT ( Financials[Price Point] ),

    Financials[Value]>0,

    Financials[Price Point] <> BLANK ()

    )

     

    This value you need to join with an independent table having value 0,1,2,3,4  (using generate series)

     

    A final measure like

     

    Similar example for details 

    Dynamic Segmentation Bucketing Binning
    https://community.powerbi.com/t5/Quick-Measures-Gallery/Dynamic-Segmentation-Bucketing-Binning/m-p/1387187#M626


    Dynamic Segmentation, Bucketing or Binning: https://youtu.be/CuczXPj0N-k

    sumx(filter(Values(Table[Customer]), [Measure] = max(Bucket[Value])),[Measure])

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Amitchandak,

       

      Thank you very much for the reply. It looks like this did the trick 🙂 Thank you very much for the fast support. Its much appreciated 

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi again Amithandak,

       

      I considering writing a new post for a follow up issue, but I thought it might be better to try it here since most of the information is here. So the solution with the buckets did work out very well.  However, one thing I have noticed is that cross filtering doesnt work as hoped between my visuals. I can pick a customer and it will filer on the price points, but I cannot filter on the number of price point visuals and get the list of customers that has that number of price points. I believe this is due to no relationship exists between the facttable and the "bucket" table. Are you aware of a way to create a relationship or another workaround to make cross filtering possible? Thank you much in advance.