Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Asantos2020
Advocate II
Advocate II

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!

 

 

1 ACCEPTED SOLUTION
v-lid-msft
Community Support
Community 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.

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.

View solution in original post

4 REPLIES 4
v-lid-msft
Community Support
Community 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.

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.

Perfect, @v-lid-msft ! Thank you!

AlB
Super User
Super User

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). 

Hi @AlB !

 

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

Imagem1.png

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.