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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
francino
Frequent Visitor

Count products below a user defined threshold

I am having trouble with getting a count of products below a user selected threshold.  Here is the scenario.  I have a table with products and their respective sales:

francino_0-1614173754604.png

 

I calculate the average sales using a measure.  Then I factor that average using a what if scenario to arrive at a threshold.

 

(MEASURE) Ave Sales = CALCULATE(sum('Table1'[Sales])/DISTINCTCOUNT('Table1'[Unit]))

Factor = 40% --> from a user defined What if Scenario

(MEASURE) Threshold = [Ave Sales]*('Factor'[Factor Value])

 

Ave Sales = 151.25

Factor = 40%

Threshold = 60.5

 

What I need to know is the number of products below that threshold.  In this example, that number should be 2.

 

I know that measures cannot be used to determine a subset of data in another measure.  I have tried dividing the Sales into the Threshold and counting the #'s less than 1 and several other approaches. 

 

Thank you in advance!

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@francino , Try measure

 


GT Threshold =
var _t = calculate([Threshold], allselected(Table))
return
countx(values(table[product]), if([sales] > _T,[product], blank()))

 

Below Threshold =
var _t = calculate([Threshold], allselected(Table))
return
countx(values(table[product]), if([sales] <_T,[product], blank()))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@francino , Try measure

 


GT Threshold =
var _t = calculate([Threshold], allselected(Table))
return
countx(values(table[product]), if([sales] > _T,[product], blank()))

 

Below Threshold =
var _t = calculate([Threshold], allselected(Table))
return
countx(values(table[product]), if([sales] <_T,[product], blank()))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thank you!  That worked.  I made just one small change to the variable by replacing your code with the Threshold measure and it all came together.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

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.