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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
DanielCarvalho
Helper III
Helper III

Count rows based on distinct value from another column

Hello Community,

 

I am trying to count how many rows I have each day for a time line chart but based on the distinct values of its ID column,

 

Basically lets say i have 2 columns , one which is the date a ticket was created and another column which is the ticket id.. As everytime a ticket changes status, the ticket is repeated in my data and another row with the same ticket id and same date is created. If i do count of my date column, for each day (in order to see how many new tickets were created each day) then it will give me innacurate results as its going to count the same ticket as many times as it is in my data. 

 

I want to count how many rows I have in that specific date but based on distinct id. 

 

DanielCarvalho_0-1679323521090.png

As seen in the print above this ticket is repeated 5 times. When I count tickets created on the 28/9/22 in this case I wanted to count as 1 and not 5 as its the same ticket with the same ID.

 

Kind Regards,

Daniel Carvalho

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @DanielCarvalho 

You can refer to the following measure

Sample data

vxinruzhumsft_2-1679367776878.png

Measure

Measure = var a=SUMMARIZE('Table','Table'[CASEID],'Table'[Date])
return COUNTAX(a,[Date])

Output

vxinruzhumsft_1-1679367758295.png

 

Best Regards!

Yolo Zhu

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

2 REPLIES 2
Anonymous
Not applicable

Hi @DanielCarvalho 

You can refer to the following measure

Sample data

vxinruzhumsft_2-1679367776878.png

Measure

Measure = var a=SUMMARIZE('Table','Table'[CASEID],'Table'[Date])
return COUNTAX(a,[Date])

Output

vxinruzhumsft_1-1679367758295.png

 

Best Regards!

Yolo Zhu

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

Thanks for the answer! 

 

I was wondering how to this in a MTD/YTD measure. Currently I have it like this but its not giving me the right results:

 

Created_Tickets(MTD) = CALCULATE(COUNT(TICKET_DASHBOARD_GAVATAR_HISTORY[ACTIONDATE_FORMATTED]),DISTINCT(TICKET_DASHBOARD_GAVATAR_HISTORY[CASEID]),DATESMTD('CALENDAR'[DATE]))
 
Created_Tickets(YTD) = CALCULATE(COUNT(TICKET_DASHBOARD_GAVATAR_HISTORY[ACTIONDATE_FORMATTED]),DISTINCT(TICKET_DASHBOARD_GAVATAR_HISTORY[CASEID]),DATESYTD('CALENDAR'[DATE], "30/9" ))
 
Kind Regards,
Daniel

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.