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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Dimitri70
Helper I
Helper I

DAX formula to count number of value base on measure

Hello, I'm getting very frustating today trying to make a new measure but not giving correct result.

 

I have this table

CommoditySupplierPart numberInventoryPast consumption
x1

xx1

101
x2xx2105
y1xx310400
y2xx4101000
y3xx510200
z1xx610300
z4xx7102

 

In power BI, I created a new measure to calculate the Inventory turn over ITO =(Past consumption /Inventory) and then I would like to create a formula to know for example when I select the commodity X, how many supplier has the Inventory turn value less than 12 (answer should be 2). And if I select commodity X and Y, it should still be 2.

I tried to use a formula such as = CALCULATE(DISTINCTCOUNT('data'[Supplier]),FILTER('data','data'[ITO]<12)) but result is not matching. 

Do you have an idea how I could proceed?

 

Thank you

1 ACCEPTED SOLUTION
venkatesh-11
Regular Visitor

Hi Dimitri Please refer my solution if its works please give thumbs up
Solution =
var table_ = ADDCOLUMNS(VALUES(solution[Commodity]),"Div",CALCULATE(DIVIDE( SUM(solution[Past consumption]),SUM(solution[Inventory]))))


RETURN
CALCULATE(DISTINCTCOUNT(solution[Supplier]),FILTER(table_, [Div] <12))

View solution in original post

10 REPLIES 10
venkatesh-11
Regular Visitor

Hi Dimitri Please refer my solution if its works please give thumbs up
Solution =
var table_ = ADDCOLUMNS(VALUES(solution[Commodity]),"Div",CALCULATE(DIVIDE( SUM(solution[Past consumption]),SUM(solution[Inventory]))))


RETURN
CALCULATE(DISTINCTCOUNT(solution[Supplier]),FILTER(table_, [Div] <12))

Thank you for the proposal, it almost work as I expext except that the formula count how many time for each supplier and commodities the ITO is lower than 12, so if supplier is serving 3 commodities that are lower than 1, it will count for 3. 

Is there possible to check just the ITO at supplier level?

from 

Dimitri70_2-1743166465288.png

 

to this

Dimitri70_1-1743166314508.png

Even if supplier has ITO per commodity <12 just considering the total ITO for the all ommodity in once.

 

Thank you very much for your support

venkatesh-11
Regular Visitor

Hi Dimitri Please refer my solution if its works please give thumbs up
Solution =
var table_ = ADDCOLUMNS(VALUES(solution[Commodity]),"Div",CALCULATE(DIVIDE( SUM(solution[Past consumption]),SUM(solution[Inventory]))))


RETURN
CALCULATE(DISTINCTCOUNT(solution[Supplier]),FILTER(table_, [Div] <12))

venkatesh-11
Regular Visitor

Hi Dimitri Please refer my solution if its works please give thumbs up
Solution =
var table_ = ADDCOLUMNS(VALUES(solution[Commodity]),"Div",CALCULATE(DIVIDE( SUM(solution[Past consumption]),SUM(solution[Inventory]))))


RETURN
CALCULATE(DISTINCTCOUNT(solution[Supplier]),FILTER(table_, [Div] <12))

venkatesh-11
Regular Visitor

Solution =
var table_ = ADDCOLUMNS(VALUES(solution[Commodity]),"Div",CALCULATE(DIVIDE( SUM(solution[Past consumption]),SUM(solution[Inventory]))))


RETURN
CALCULATE(DISTINCTCOUNT(solution[Supplier]),FILTER(table_,[Div] <12))

venkatesh-11
Regular Visitor

Hello  

 ,

Please find below my solution regarding your ask please use  this 

Solution =
var table_ = ADDCOLUMNS(VALUES(solution[Commodity]),"Div",CALCULATE(DIVIDE( SUM(solution[Past consumption]),SUM(solution[Inventory]))))


RETURN
CALCULATE(DISTINCTCOUNT(solution[Supplier]),FILTER(table_,[Div] <12))

venkatesh11_0-1743147546835.png

 



Dimitri70
Helper I
Helper I

Thank you for the suggestion, I tried but I get same result.

from the moment where a supplier has a part number in the commodity with the ITO<12, it is count as 1 even if the total value of ITO per supplier &commodity is >12.

Hi,

Please share your sample pbix file's link (onedrive or dropbox or googlelink or else) here, and then I can try to look into it.

Thank you.


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.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how it is created, but if you try to create calcualted column like the below, I think it is working.
please check the below picture and the attached pbix file.

 

Jihwan_Kim_0-1743133999757.png

 

this is calculated column

ITO CC = 
data[Past consumption] / data[Inventory]

 

this is measure.

expected result measure: = 
CALCULATE ( DISTINCTCOUNT ( 'data'[Supplier] ), 'data'[ITO CC] < 12 )

 


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.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Sorry I cant sent as it is sensitive data.

But below this is to show my issue:

You can see below at supplier level ITO is 43 so higher than 12 but formula still give 1 as answer 

Dimitri70_1-1743137930999.png

Then at supplier and commodity level: Still formula give 1 even if ITO is higher than 12

Dimitri70_0-1743137865494.png

By deepdown I can see the 1 is coming because 1 part number.

Dimitri70_2-1743138072052.png

 

Is there a way to considere supplier level?

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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