Forum Discussion

Asantos2020's avatar
Asantos2020
Icon for Advocate II rankAdvocate II
6 years ago
Solved

Have a DistinctCount Measure shown in a card visual

Hello folks,

I've been using the DAX Measure below, which works fine on a table and where it helps me identify customers who have bought a specific product. However, I now need to have its total shown on a card visual and I can't find a way to do so.

 

Customers who didn't buy2 = IF(
                            HASONEVALUE(Products[Products]);
                            CALCULATE(
                                DISTINCTCOUNT(BI_Sales[ClientId]);
                                FILTER(BI_Sales;NOT(CONTAINs(BI_Sales;BI_Sales[Produtos];VALUES(Products[Products]))))
                            );
                            DISTINCTCOUNT(BI_Sales[ClienteId])
                            )

Thank you!

 

 

  • Hi Asantos2020 ,

     

    We can try to use the following measure, change the customer and id in formula to the column you used in table visual.

     

     

    TotalCount =
    SUMX (
        VALUES ( 'Customer'[CustomerID] ),
        IF ( CALCULATE ( [Customers who didn't buy2] ) = 1, 1, BLANK () )
    )


    If it doesn't meet your requirement, kindly share your sample data and expected result to me if you don't have any Confidential Information. Please upload your files to One Drive and share the link here.

     

     

    Best regards,

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

4 Replies

  • AlB's avatar
    AlB
    Icon for Community Champion rankCommunity Champion

    Hi Asantos2020 

    When you say it "works fine in a table" you mean a table visual? or a real data table? Can you provide details on how exactly you are using the measure now (what fields go on the visual and what your data model looks like). 

    • Asantos2020's avatar
      Asantos2020
      Icon for Advocate II rankAdvocate II

      Hi AlB !

       

      Details are below. I've greyed out ClienteFantasia and Últ. Vendedor for confidentiality purposes, but I guess the rest clarifies:

  • v-lid-msft's avatar
    v-lid-msft
    Icon for Community Support rankCommunity Support

    Hi Asantos2020 ,

     

    We can try to use the following measure, change the customer and id in formula to the column you used in table visual.

     

     

    TotalCount =
    SUMX (
        VALUES ( 'Customer'[CustomerID] ),
        IF ( CALCULATE ( [Customers who didn't buy2] ) = 1, 1, BLANK () )
    )


    If it doesn't meet your requirement, kindly share your sample data and expected result to me if you don't have any Confidential Information. Please upload your files to One Drive and share the link here.

     

     

    Best regards,

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