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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
DanielCarvalho
Helper III
Helper III

MTD/YTD on count of a column based on distinct values of another

Hello Community,

 

I am trying to create 2 measures (MTD/YTD) as I created the other ones and they work fine but in my current case I need to count how many entries are in each one of those months based on a distinct value of a collumn:

DanielCarvalho_0-1679390232471.png

As seen above, imagine that i was doing MTD of this data I would want the count of septmeber to be only 1 as its the same case ID and not be 5 as the data reoeats when that case ID changes status but the creating data(action date stays the same)

 

The measures I tried are the following:

 

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" ))
 
This usually works fine without the distinct part but this time I really need it to only count based on the distinct case ID.
 
What is the best way to do this? 
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @DanielCarvalho ,

Please update the formula of measure [Created_Tickets(MTD)] and [Created_Tickets(YTD)] as below and check if they can return the expected result...

Created_Tickets(MTD) =
CALCULATE (
    DISTINCTCOUNT ( TICKET_DASHBOARD_GAVATAR_HISTORY[CASEID] ),
    DATESMTD ( 'CALENDAR'[DATE] )
)
Created_Tickets(YTD) =
CALCULATE (
    DISTINCTCOUNT ( TICKET_DASHBOARD_GAVATAR_HISTORY[CASEID] ),
    DATESYTD ( 'CALENDAR'[DATE], "30/9" )
)

If the above one can't help you, please provide some raw data in your table 'TICKET_DASHBOARD_GAVATAR_HISTORY' (exclude sensitive data) with Text format and your expected result with backend logic and special examples? Please also provide the related info if there is any relationship between the table 'TICKET_DASHBOARD_GAVATAR_HISTORY' and CALENDAR table. It would be helpful to find out the solution. You can refer the following links to share the required info:

How to provide sample data in the Power BI Forum

How to Get Your Question Answered Quickly

And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @DanielCarvalho ,

Please update the formula of measure [Created_Tickets(MTD)] and [Created_Tickets(YTD)] as below and check if they can return the expected result...

Created_Tickets(MTD) =
CALCULATE (
    DISTINCTCOUNT ( TICKET_DASHBOARD_GAVATAR_HISTORY[CASEID] ),
    DATESMTD ( 'CALENDAR'[DATE] )
)
Created_Tickets(YTD) =
CALCULATE (
    DISTINCTCOUNT ( TICKET_DASHBOARD_GAVATAR_HISTORY[CASEID] ),
    DATESYTD ( 'CALENDAR'[DATE], "30/9" )
)

If the above one can't help you, please provide some raw data in your table 'TICKET_DASHBOARD_GAVATAR_HISTORY' (exclude sensitive data) with Text format and your expected result with backend logic and special examples? Please also provide the related info if there is any relationship between the table 'TICKET_DASHBOARD_GAVATAR_HISTORY' and CALENDAR table. It would be helpful to find out the solution. You can refer the following links to share the required info:

How to provide sample data in the Power BI Forum

How to Get Your Question Answered Quickly

And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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