Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
Hi all,
I need to count the distinct # of suppliers with products having a lower margin than a field parameter. Assuming the user selects 5% as parameter, I would like to have 2 for suppliers count from the example below (A and C).
Supplier | Product | Margin | COUNT DISTINCT |
A | 1 | 1% | A |
A | 2 | 2% | A |
B | 3 | 10% | |
C | 4 | 4% | C |
As the field parameter is dynamic, I cannot use a calculated column which will only use the default value of the parameter but not update dynamically.
In SQL, I would use something like COUNT DISTINCT (IF margin < parameter then supplier else null)
What DAX formula can I use for similar result?
Thanks in advance for your help
BR
Solved! Go to Solution.
Hi @MrBlueSky2
Please use below code
SuppliersWithLowMarginCount =
VAR LowMarginSuppliers =
CALCULATETABLE(
DISTINCT('Table'[Supplier]),
'Table'[Margin] < [FieldParameter]
)
RETURN
COUNTROWS(LowMarginSuppliers)
Regards
Govind Sapkade ( Data Analyst , Power BI PL 300 Certified , MS Fabric Enthusiast )
Linkdin : www.linkedin.com/in/govind-sapkade-845104225
Youtube : http://www.youtube.com/@govind_dataanalyst
Hi @MrBlueSky2
Please use below code
SuppliersWithLowMarginCount =
VAR LowMarginSuppliers =
CALCULATETABLE(
DISTINCT('Table'[Supplier]),
'Table'[Margin] < [FieldParameter]
)
RETURN
COUNTROWS(LowMarginSuppliers)
Regards
Govind Sapkade ( Data Analyst , Power BI PL 300 Certified , MS Fabric Enthusiast )
Linkdin : www.linkedin.com/in/govind-sapkade-845104225
Youtube : http://www.youtube.com/@govind_dataanalyst
@MrBlueSky2 , Try using
dax
SuppliersWithLowMarginCount =
CALCULATE(
COUNTROWS(
DISTINCT('Table'[Supplier])
),
FILTER(
'Table',
'Table'[Margin] < [FieldParameter]
)
)
Proud to be a Super User! |
|
User | Count |
---|---|
15 | |
9 | |
8 | |
6 | |
5 |
User | Count |
---|---|
30 | |
19 | |
12 | |
7 | |
5 |