Forum Discussion
GrimReaperX
4 years agoHelper II
Counting distinct values based on criteria
Hello guys, I have a data where PO number, cost center and division is given. Based on specific cost center a PO is considered either division A or B. It is possible a PO number might have more ...
- 4 years ago
See attached file for a possible solution
Measure = VAR currentDept_ = SELECTEDVALUE(Table1[Dept]) RETURN CALCULATE( VAR auxT_ = ADDCOLUMNS(ALL(Table1[PO]), "@CC", CALCULATE(MIN(Table1[CostCenter]))) VAR auxT2_ = ADDCOLUMNS(auxT_, "@Dept", CALCULATE(MAX(Table1[Dept]))) RETURN COUNTROWS(FILTER(auxT2_, [@Dept] = currentDept_)) , ALL(Table1[Dept]))Please accept the solution when done and consider giving a thumbs up if posts are helpful.
Contact me privately for support with any larger-scale BI needs, tutoring, etc.
Anonymous
4 years agoNot applicable
Hello*
Try these 2 measures
calculation IT =
var ponbr=selectedvalue(Feuil2[PO Number])
var _step1=
filter(
ADDCOLUMNS (
SUMMARIZE ( Feuil2, Feuil2[PO Number] ),
"@on IT",
CALCULATE (
COUNT ( Feuil2[Division] ),
ALLEXCEPT ( Feuil2, Feuil2[PO Number] ),
Feuil2[Division] = "IT"
)
),[@on IT]>0)
var result=
countrows(_step1)
return
result
calculation FIN =
var ponbr=selectedvalue(Feuil2[PO Number])
var _step1=
filter(
ADDCOLUMNS (
SUMMARIZE ( Feuil2, Feuil2[PO Number] ),
"@on IT",
CALCULATE (
COUNT ( Feuil2[Division] ),
ALLEXCEPT ( Feuil2, Feuil2[PO Number] ),
Feuil2[Division] = "IT"
)
),[@on IT]=0)
var result=
countrows(_step1)
return
result