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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Vladimir_NBG
Helper I
Helper I

Numeric distribution - How to create measure

Hi All,

I would need help in calculating numeric distribution, in terms how to exactly set up a formula.

So, in the table below there is "dummy" numbers.

I need formula that will distinct count only those stores where certain product has positive quantity on total.

Pay attention on PRODUCT A, and STORE CODE 1.

 

PRODUCT NAMESTORE CODESALES QUANTITY
PRODUCT A138
PRODUCT B167
PRODUCT C122
PRODUCT A225
PRODUCT A1-39
PRODUCT C234
PRODUCT B325
PRODUCT A438

 

This is the result i would like to get through formula (i put explanation column only for additional clarification):

 

PRODUCTDISTRIBUTION (NUMBER OF STORES)EXPLANATION         
PRODUCT A2STORE CODES 2 & 4   ---> STORE 1 IS NOT COUNTED BECAUSE THE TOTAL QUANTITY FOR THIS PRODUCT IS -1
PRODUCT B2STORE CODES 1 & 3         
PRODUCT C2STORE CODES 1 & 2         
            

 

Thank you very much in advance!

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi, @Vladimir_NBG 

Please check the below picture and the sample pbix file's link down below.

 

Picture4.png

 

Distribution (Number of stores) =
IF (
ISFILTERED ( 'Table'[PRODUCT NAME] ),
COUNTROWS (
FILTER (
VALUES ( 'Table'[STORE CODE] ),
CALCULATE ( SUM ( 'Table'[SALES QUANTITY] ) ) > 0
)
)
)

 

 

https://www.dropbox.com/s/9tebnnhih3fsikd/vladimir.pbix?dl=0 

 

 

Hi, My name is Jihwan Kim.

 

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

 

Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM


 

    Microsoft MVP
 

 

   


      If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


   


     
        LinkedInVisit my LinkedIn page
     

   


   


     
        Outlook BookingSchedule a short Teams meeting to discuss your question

     

   


 


View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi, @Vladimir_NBG 

Please check the below picture and the sample pbix file's link down below.

 

Picture4.png

 

Distribution (Number of stores) =
IF (
ISFILTERED ( 'Table'[PRODUCT NAME] ),
COUNTROWS (
FILTER (
VALUES ( 'Table'[STORE CODE] ),
CALCULATE ( SUM ( 'Table'[SALES QUANTITY] ) ) > 0
)
)
)

 

 

https://www.dropbox.com/s/9tebnnhih3fsikd/vladimir.pbix?dl=0 

 

 

Hi, My name is Jihwan Kim.

 

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

 

Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM


 

    Microsoft MVP
 

 

   


      If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


   


     
        LinkedInVisit my LinkedIn page
     

   


   


     
        Outlook BookingSchedule a short Teams meeting to discuss your question

     

   


 


Thank you Jihvan! I applied it on my data and it works.

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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

Top Solution Authors