Forum Discussion
Count distinct based on another column value
Hello!, I´m a beginner in Power Bi and have this problem:
I 'm filtering my Table, based on 'Articulo' Column. I need to create a new measure (to put in a card) ,equals to= 'Curva_Completa' Column/ Distinct count of Talle, only if 'Sucursal' column exists.... the result shoould be : 2/11.
2, because we have 2 different rows (5.5 and 6) and 11 because of 'Curva_Completa' Column (it comes from an over partition from sql, so its the same value for each row from 'Articulo' Column) and. Is it possible?
Thanks in advance!
Hi Anonymous
Try this measure:
Measure = Var _A = MAX('Table'[Curva_Completa]) Var _B = CALCULATE(DISTINCTCOUNT('Table'[Talle]),FILTER('Table','Table'[Sucursal]<>blank())) return _A/_BIf this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: www.linkedin.com/in/vahid-dm/Hi Anonymous ,
Here my solution:
And here the code for the measure:
TomsDivisionMeasure = VAR _curvaCompleta = MAX ( Table[Curva_Completa] ) RETURN CALCULATE ( DIVIDE ( _curvaCompleta, DISTINCTCOUNT ( Table[Talle] ) ) , Table[Sucursal] <> BLANK() )Hope this helps! 🙂
/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/
4 Replies
- VahidDMSuper User
Hi Anonymous
Try this measure:
Measure = Var _A = MAX('Table'[Curva_Completa]) Var _B = CALCULATE(DISTINCTCOUNT('Table'[Talle]),FILTER('Table','Table'[Sucursal]<>blank())) return _A/_BIf this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: www.linkedin.com/in/vahid-dm/ - tackytechtomMost Valuable Professional
Hi Anonymous ,
Here my solution:
And here the code for the measure:
TomsDivisionMeasure = VAR _curvaCompleta = MAX ( Table[Curva_Completa] ) RETURN CALCULATE ( DIVIDE ( _curvaCompleta, DISTINCTCOUNT ( Table[Talle] ) ) , Table[Sucursal] <> BLANK() )Hope this helps! 🙂
/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/- AnonymousNot applicable
thanks a lot tackytechtom, it worked fine!
- AnonymousNot applicable
Thanks VahidDM , this was very helpful!! 🙂