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

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

Reply
dsilveira
Advocate I
Advocate I

Problem with GROUP BY and show dates in Slicer

Hi!

I need your help, I have spent a long time in this project and I haven't found the solution still.

I need to show all the times is searched a terms in the web. Por example, if the user search the name "Jim", in the data base is saved:

Name    Date

Jim      '01/01/2016'

 

I would like count how count often is searched each name. If I have in my Datebase:

Name    Date

Jim      '01/01/2016'

Tom     '12/23/2002'

Jim       '06/19/2006'

Mary    '03/14/2004'

 

I can return 

Name     Count

Jim            2

Tom          1

Mary         1

With this query: 

SELECT name, COUNT(*) FROM myTable
GROUP BY name
ORDER BY COUNT(*)

BUT I would like keep the dates because I need to show the quantity of search in some dates (like the user want to select). The dates is no important for me show it in my grid table in Power BI Desktop; the dates is important for use my Slicer.

Capture.JPG

Maybe it is no the correct title for my problem... I'm sorry for my English, it isn't my native laguage.

 

I'll appreciate your help.

 

Thanks in advance!

 

 

 

 

 

 

 

2 REPLIES 2
v-ljerr-msft
Microsoft Employee
Microsoft Employee

@dsilveira

 

In addition to ankitpatira's solution, you can just import the table into Power BI with the SQL query like below.

SELECT name, date FROM myTable

myTable.PNG

Then you should be able to create a measure like below to calculate the searched count of each name, and show it in the report. In the meantime, you can still use Date as a Slicer.

CountOfName = COUNTA(myTable[Name])

countAndSlicer.PNG

Regards

ankitpatira
Community Champion
Community Champion

@dsilveira In that case your sql query would be as below and you will get count by dates. Then in slicer for power bi destkop drop date field and click on dropdown icon and instead of date hierarchy choose just date.

 

SELECT name, date, COUNT(*) FROM myTable
GROUP BY name, date
ORDER BY COUNT(*)

 

Helpful resources

Announcements
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