The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
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:
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!
Solved! Go to Solution.
@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()))
@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()))
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.
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the August 2024 Power BI update to learn about new features.
User | Count |
---|---|
109 | |
77 | |
70 | |
48 | |
41 |
User | Count |
---|---|
140 | |
112 | |
72 | |
64 | |
63 |