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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Jay2022
Helper III
Helper III

Remove duplicates and count from date column in new table

 

I have selected a dates column from another table and i now have them in a new column  

Select Col =
SELECTCOLUMNS('Table')
,"Dates", 'Table'[Dates column])

 

 

I have then changed the format of the dates to MMM,Year 

so i have

Jan24 

Feb 24

Feb 24 

Mar 24 

etc 

 

I now want to 

1 - remove duplicates

2- count the number of occurances for each month eg 

Jan 24 - 5 

Feb 24 - 2 etc 

 

Do I do as above and count the occurances from the Dates Column from th eoriginal table or do i add another column to this table the same as Dates only without the duplciates and then count from the table containing the duplicates. 

 

so it woudl look like 

Dates, Date_excluding_duplicates, Count

 

Any help really apprecaited

 

1 ACCEPTED SOLUTION
v-tangjie-msft
Community Support
Community Support

Hi @Jay2022 ,

 

Thanks bhanu_gautam  for the quick reply. I have some other thoughts to add:

(1) We can create a new table.

Col = 
SELECTCOLUMNS('Table'
,"Dates", 'Table'[Date column])

(2) We can create columns on Col table.

MMM_Year = FORMAT([Dates],"MMM yy")
Count = COUNTROWS(FILTER('Col',[MMM_Year]=EARLIER('Col'[MMM_Year])))

vtangjiemsft_0-1731032750389.png

 

(3) We can create a SUMMARIZE table.

SUMMARIZE Table = SUMMARIZE('Col',[MMM_Year],[Count])

vtangjiemsft_1-1731032760763.png

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

View solution in original post

5 REPLIES 5
v-tangjie-msft
Community Support
Community Support

Hi @Jay2022 ,

 

Thanks bhanu_gautam  for the quick reply. I have some other thoughts to add:

(1) We can create a new table.

Col = 
SELECTCOLUMNS('Table'
,"Dates", 'Table'[Date column])

(2) We can create columns on Col table.

MMM_Year = FORMAT([Dates],"MMM yy")
Count = COUNTROWS(FILTER('Col',[MMM_Year]=EARLIER('Col'[MMM_Year])))

vtangjiemsft_0-1731032750389.png

 

(3) We can create a SUMMARIZE table.

SUMMARIZE Table = SUMMARIZE('Col',[MMM_Year],[Count])

vtangjiemsft_1-1731032760763.png

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

Jay2022
Helper III
Helper III

are these each 3 seperate tables ? 

Jay2022
Helper III
Helper III

i get the following  error     The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value.

Jay2022
Helper III
Helper III

Thanks first bit works fine but getting stuck on this bit 

 

Format the dates to "MMM, Year":
FormattedDatesWithCount =
ADDCOLUMNS(
UniqueDatesWithCount,
"FormattedDate", FORMAT('Table'[Dates column], "MMM yy")
)

 

after FORMAT shoudl it be (UniqueDateswithCount'[Dates colum] basically from the new column i created

bhanu_gautam
Super User
Super User

@Jay2022 , Use below steps

Create a new table with unique dates and their counts:
UniqueDatesWithCount =
SUMMARIZE(
'Table',
'Table'[Dates column],
"Count", COUNT('Table'[Dates column])
)


Format the dates to "MMM, Year":
FormattedDatesWithCount =
ADDCOLUMNS(
UniqueDatesWithCount,
"FormattedDate", FORMAT('Table'[Dates column], "MMM yy")
)


Remove duplicates and count occurrences:
FinalTable =
SUMMARIZE(
FormattedDatesWithCount,
[FormattedDate],
"Count", SUM([Count])
)
This will give you a table with the formatted dates and their counts without duplicates.




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.