Forum Discussion
To find distinct no from same column
Hi all need help to find the distinct count from a same column between two dates. In the below data May month has X1,X2,X3,X4 &X5 and June month has X1,X2,X3 & X6. So X6 is the new number and the count is 1 for the month of June. Kindly help.
DateTool
| 01-05-2020 | X1 |
| 01-05-2020 | X2 |
| 01-05-2020 | X3 |
| 01-05-2020 | X4 |
| 01-05-2020 | X5 |
| 20-06-2020 | X1 |
| 20-06-2020 | X2 |
| 20-06-2020 | X3 |
| 20-06-2020 | X6 |
harshagraj try following measure
New Count = VAR __firstDate = EOMONTH ( MAX ( Table[Date] ), -1 ) + 1 VAR __prevTools = CACLULATETABLE ( VALUES ( Table[Tool] ), Table[Date] < __firstDate ) RETURN CALCULATE ( COUNTROWS ( Table ), EXCEPT ( VALUES ( Table[Tool] ), __prevTools ) )Most likely need bit of tweaking but yo have the gist.
I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!
⚡Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.⚡
harshagraj don't remember but change it like this
New Count = VAR __firstDate = EOMONTH ( MAX ( Table[Date] ), -1 ) + 1 VAR __prevTools = CACLULATETABLE ( VALUES ( Table[Tool] ), Table[Date] < __firstDate ) RETURN CALCULATE ( DISTINCTCOUNT ( Table[Tool] ), EXCEPT ( VALUES ( Table[Tool] ), __prevTools ) )I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!
⚡Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.⚡
10 Replies
- parry2k
Super User
harshagraj try following measure
New Count = VAR __firstDate = EOMONTH ( MAX ( Table[Date] ), -1 ) + 1 VAR __prevTools = CACLULATETABLE ( VALUES ( Table[Tool] ), Table[Date] < __firstDate ) RETURN CALCULATE ( COUNTROWS ( Table ), EXCEPT ( VALUES ( Table[Tool] ), __prevTools ) )Most likely need bit of tweaking but yo have the gist.
I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!
⚡Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.⚡
- harshagraj
Post Partisan
Hi parry2k thank you so much it worked perfectly.
- harshagraj
Post Partisan
14-01-2020 14-01-2020 1944653 14-01-2020 1829492 14-01-2020 1829990 14-01-2020 1949860 14-01-2020 1949861 14-01-2020 1880739 14-01-2020 1880739 14-01-2020 1880739 14-01-2020 1880894 14-01-2020 xxxxxxx 31-01-2020 31-01-2020 1944653 31-01-2020 1829492 31-01-2020 1947977 31-01-2020 1949296 31-01-2020 1951637 31-01-2020 1952268 31-01-2020 1952269 31-01-2020 1952270 31-01-2020 1952360 21-02-2020 1949786 21-02-2020 1949786 21-02-2020 1952878 21-02-2020 1952878 21-02-2020 513002 21-02-2020 3704900 21-02-2020 1880816 21-02-2020 1950063 21-02-2020 xxxxxxx 28-02-2020 28-02-2020 1944653 28-02-2020 1945212 28-02-2020 1945212 28-02-2020 1945212 28-02-2020 1945212 28-02-2020 1945212 28-02-2020 1945212 28-02-2020 1945213 28-02-2020 1945213 28-02-2020 1949786 28-02-2020 1949786 28-02-2020 1949786 28-02-2020 1952878 28-02-2020 1952878 28-02-2020 513002 28-02-2020 3704900 28-02-2020 1880816 28-02-2020 1950063
- harshagraj
Post Partisan
Hi parry2k i have a small problem now. Can this calculation be done on Tool context? Like All except (Tool).
The problem what is happening is in the month of Nov 2019 when i export the data i have only 81 tool no's but when i check in Power BI as count of tool it shows 266. - harshagraj
Post Partisan
Hi parry2k please help me to get the distinct ones.
- parry2k
Super User
harshagraj not fully sure what you are looking for, can you share sample excel file and expected output. Thanks!