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
Guenfood77
Frequent Visitor

Count value based on measure

Hi,

 

I need to count values in a column based on a measure.

Exemple : I've got a measure to count number of product A. I want to count number of others products (except A) for same Id

For John : 1 product A with my first measure. I must have 2 with the second measure

 

CustomerProductDateId
JohnA10/01/2024John10012004
PaulB12/01/2024Paul12012024
SarahA13/01/2024Sarah13012024
PaulB12/01/2024Paul12012024
JohnB10/01/2024John10012024
SarahA13/01/2024Sarah13012024
PaulC12/01/2024Paul12012024
JohnC10/01/2024John10012024

 

Thanks for your help

1 ACCEPTED SOLUTION
v-yaningy-msft
Community Support
Community Support

Hi, @Guenfood77 

 

Based on your description, I have created many measures to achieve the effect you are looking for. Following picture shows the effect of the display.

 

vyaningymsft_0-1707895600477.png

 

Measure:

 

Count of Product =

VAR _A =

    CALCULATE ( COUNTROWS ( 'Table' ), 'Table'[Product] = "A", ALL ( 'Table' ) )

VAR _nonA =

    CALCULATE ( COUNTROWS ( 'Table' ), ALLEXCEPT ( 'Table', 'Table'[Id] ) )

RETURN

    IF ( SELECTEDVALUE ( 'Table'[Product] ) = "A", _A, _nonA )

 

 

If this does not work, could you please share some sample data without sensitive information and expected output(You can present the desired effect in a table, as well as a detailed description of the logic to achieve this effect).
How to provide sample data in the Power BI Forum - Microsoft Fabric Community

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

 

 

View solution in original post

2 REPLIES 2
Guenfood77
Frequent Visitor

Thanks for your help. It works nice !

v-yaningy-msft
Community Support
Community Support

Hi, @Guenfood77 

 

Based on your description, I have created many measures to achieve the effect you are looking for. Following picture shows the effect of the display.

 

vyaningymsft_0-1707895600477.png

 

Measure:

 

Count of Product =

VAR _A =

    CALCULATE ( COUNTROWS ( 'Table' ), 'Table'[Product] = "A", ALL ( 'Table' ) )

VAR _nonA =

    CALCULATE ( COUNTROWS ( 'Table' ), ALLEXCEPT ( 'Table', 'Table'[Id] ) )

RETURN

    IF ( SELECTEDVALUE ( 'Table'[Product] ) = "A", _A, _nonA )

 

 

If this does not work, could you please share some sample data without sensitive information and expected output(You can present the desired effect in a table, as well as a detailed description of the logic to achieve this effect).
How to provide sample data in the Power BI Forum - Microsoft Fabric Community

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

 

 

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.