Forum Discussion

Kevin_Gitonga's avatar
7 years ago
Solved

Aggregating Distinct Count measure and Aggregating IF measure

I have the following matrix table with the columns being products and the rows being the customer codes. What I want is to find the billings which is the distinct count of orders.I used the following...
  • v-jiascu-msft's avatar
    7 years ago

    Hi Kevin_Gitonga,

     

    Try these two measures, please.

     

    Measure =
    SUMX (
        SUMMARIZE (
            'table',
            'table'[ProductCode],
            'table'[CustomerCode],
            "Billing", DISTINCTCOUNT ( 'table'[InvNumber] )
        ),
        [Billing]
    )
    
    Total Golden Point =
    SUMX (
        SUMMARIZE (
            'table',
            'table'[ProductCode],
            'table'[CustomerCode],
            "Golden Point", IF ( DISTINCTCOUNT ( 'table'[InvNumber] ) >= 1, 1, 0 )
        ),
        [Billing]
    )
    

     

     

     

    Best Regards,

  • Ashish_Mathur's avatar
    Ashish_Mathur
    7 years ago

    Hi,

     

    Try this measure

     

    Billing = if(HASONEVALUE(Data[ProductCode]),DISTINCTCOUNT(Data[InvNumber]),SUMX(SUMMARIZE(VALUES(Data[ProductCode]),[ProductCode],"ABCD",DISTINCTCOUNT(Data[InvNumber])),[ABCD]))

    Hope this helps.

  • Ashish_Mathur's avatar
    Ashish_Mathur
    7 years ago

    Hi,

    The Golden Points measure can be revised to:

    Golden Point = SUMX(SUMMARIZE(GENERATE(VALUES(Sales[CustomerCode]),VALUES(Sales[ProductCode])),[CustomerCode],[ProductCode],"ABCD",if(DISTINCTCOUNT(Sales[InvNumber])>=1,1,0)),[ABCD])

    Hope this helps.