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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. 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()))

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

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

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.