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.
I have a survay data. I need to find the positive %. So in the Positive column we will be counting the total 1. and that count should be divided by total distinct dount of ID. and for 2021 i have to use the FILTER
now the formula is Positive%= calculate(count (Positive)/distinct count(ID),filter (Year =2021).
Now the ussue is that if ant of the employee if his positive is coming as 0 then their ID is not counting. I need the distinct count of all ID irresoective of Positive 1 0r 0. how can i do that. below is the sample.
ID | Name | Attri | Positive | Negative | year |
12 | James | Helath | 1 | 1 | 2021 |
12 | James | Pay | 0 | 2 | 2021 |
12 | James | Transport | 1 | 1 | 2021 |
13 | Rex | Helath | 0 | 2 | 2021 |
13 | Rex | Pay | 1 | 1 | 2021 |
13 | Rex | Transport | 0 | 2 | 2021 |
14 | Sam | Helath | 0 | 1 | 2021 |
14 | Sam | Pay | 0 | 2 | 2021 |
14 | Sam | Transport | 0 | 3 | 2021 |
12 | James | Helath | 0 | 1 | 2020 |
12 | James | Pay | 0 | 2 | 2020 |
12 | James | Transport | 0 | 1 | 2020 |
13 | Rex | Helath | 0 | 2 | 2020 |
13 | Rex | Pay | 1 | 1 | 2020 |
13 | Rex | Transport | 0 | 2 | 2020 |
14 | Sam | Helath | 0 | 1 | 2020 |
14 | Sam | Pay | 0 | 2 | 2020 |
14 | Sam | Transport | 0 | 3 | 2020 |
Solved! Go to Solution.
Measure =
VAR __Table = FILTER('Table',[year]=2021)
VAR __Denominator = COUNTROWS(DISTINCT(SELECTCOLUMNS(__Table,"ID",[ID])))
VAR __Numerator = COUNTROWS(DISTINCT(SELECTCOLUMNS(FILTER(__Table,[Positive]=1),"ID",[ID])))
RETURN
DIVIDE(__Numerator,__Denominator,0)
@unnijoy Try:
@unnijoy Seems like:
COUNTROWS(DISTINCT(SELECTCOLUMNS(FILTER('Table',[year]=2021),"ID",[ID])))
hi @Greg_Deckler ,
thanks for the qucik reply. can i need the filter in over all. Like = count (positive)/dist(ID),filter 2021. How can i achive this
hi @Greg_Deckler , as per the above table the expected result is as follows.
positive = 2
total dist count of id = 3. as u can see that the for the third guy positive is coming as 0 but still we need to count him.
Positive % = 2/3= 67 %
Measure =
VAR __Table = FILTER('Table',[year]=2021)
VAR __Denominator = COUNTROWS(DISTINCT(SELECTCOLUMNS(__Table,"ID",[ID])))
VAR __Numerator = COUNTROWS(DISTINCT(SELECTCOLUMNS(FILTER(__Table,[Positive]=1),"ID",[ID])))
RETURN
DIVIDE(__Numerator,__Denominator,0)
@unnijoy Try:
User | Count |
---|---|
65 | |
62 | |
59 | |
54 | |
28 |
User | Count |
---|---|
181 | |
82 | |
66 | |
47 | |
44 |