Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
harshagraj
Post Partisan
Post Partisan

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-2020X1
01-05-2020X2
01-05-2020X3
01-05-2020X4
01-05-2020X5
20-06-2020X1
20-06-2020X2
20-06-2020X3
20-06-2020X6

 

2 ACCEPTED SOLUTIONS
parry2k
Super User
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.

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

@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.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

10 REPLIES 10
parry2k
Super User
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.

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Hi @parry2k please help me to get the distinct ones.

@harshagraj not fully sure what you are looking for, can you share sample excel file and expected output. Thanks!



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Hi @parry2k  the solution you provided is working but it is giving me the count of tools but i need distinct counts.

@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.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

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.

Hi @parry2k  thank you so much it worked perfectly.

14-01-2020 
14-01-20201944653
14-01-20201829492
14-01-20201829990
14-01-20201949860
14-01-20201949861
14-01-20201880739
14-01-20201880739
14-01-20201880739
14-01-20201880894
14-01-2020xxxxxxx
31-01-2020 
31-01-20201944653
31-01-20201829492
31-01-20201947977
31-01-20201949296
31-01-20201951637
31-01-20201952268
31-01-20201952269
31-01-20201952270
31-01-20201952360
21-02-20201949786
21-02-20201949786
21-02-20201952878
21-02-20201952878
21-02-2020513002
21-02-20203704900
21-02-20201880816
21-02-20201950063
21-02-2020xxxxxxx
28-02-2020 
28-02-20201944653
28-02-20201945212
28-02-20201945212
28-02-20201945212
28-02-20201945212
28-02-20201945212
28-02-20201945212
28-02-20201945213
28-02-20201945213
28-02-20201949786
28-02-20201949786
28-02-20201949786
28-02-20201952878
28-02-20201952878
28-02-2020513002
28-02-20203704900
28-02-20201880816
28-02-20201950063

Hi @harshnathani could you please help me!

Hi @harshagraj ,

 

 

What is X1, X2 X3.. in your sample data.

 

Can you share .pbix file pls.

 

Regards,

Harsh Nathani

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors