The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
Hi Guys,
I have been stumped for days trying to figure out how to get the correct result. I am sure I cannot see the wood for the trees and nothing I try seems to work. I am sure there must be a simple answer. Looking for some help.
I have a table (QCInspections) which among other things contains a list of supplier codes, a number of units which passed inspection, and a total number inspected. Something like this...
Supplier Code | Passed | Inspected |
AAAAA | 25 | 30 |
BBBBB | 49 | 50 |
CCCCC | 2 | 100 |
I have created 2 measures one to calculate the pass rate :
Units_Pass_Rate = DIVIDE([Passed],[Inspected])
And another to sort suppliers into groups based on the pass rate:
group_supplier =
SWITCH(
TRUE,
[Units_Pass_Rate] >=0.95, 1,
[Units_Pass_Rate] >=0.90 && [Units_Pass_Rate] < 0.95, 2,
[Units_Pass_Rate] <0.90, 3,
4)
What I am trying to do for a given filter context is count the number of suppliers in group 1 (>=0.95) and put the result into a card. Sounds simple?
This is the measure I have created to do this, however I simply cannot get the filter to work. I get a result, however the result counts all suppliers. It does not count only the suppliers.
count_group1_suppliers =
VAR supplier_group =
ADDCOLUMNS (
VALUES(QCInspections[Supplier_Code]),
"@Group", [GroupSupplier] )
VAR result =
CALCULATE (COUNTROWS(supplier_group), FILTER (supplier_group, [@Group] = 1))
RETURN result
For the life of me, I cannot get this to work. It feels like this should be really simple, but I am messing around with calculated tables and not getting any joy. Does anyone have any ideas.
Solved! Go to Solution.
@niirusan , calculated Tables and columns can not use slicer values. so no benefit of filtering them with meausre.
A var table inside the measure can get filtered
@niirusan , calculated Tables and columns can not use slicer values. so no benefit of filtering them with meausre.
A var table inside the measure can get filtered
HI @amitchandak ,
Thanks for your response. I am not quite sure what you mean. Is 'supplier_group' not a var table?
VAR supplier_group =
ADDCOLUMNS (
VALUES(QCInspections[Supplier_Code]),
"@Group", [GroupSupplier] )
If not, then what is?
Apologies if this is a DAX 101 question?
User | Count |
---|---|
65 | |
62 | |
60 | |
53 | |
28 |
User | Count |
---|---|
181 | |
82 | |
67 | |
47 | |
44 |