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

The FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now

Reply
Anonymous
Not applicable

TOTALYTD in Distinct count

Hi Team,

I am new to Bi and a requirement came in front of me to show the data in a cummulative way. I was using the TotalYTD for the same but the expression which i am using in YTD contains the DISTINCT COUNT not the sum. I don't know whether the YTD works for DISTINCTCOUNT or not. For better understanding below is the measure which i am using in YTD. 
DAX QUERY = CALCULATE(DISTINCTCOUNT('SA Program'[Self Assessment Program Tracker Number]).

 

The problem statement something like this. Suppose in a year 2021 i have 40 programs, 2022 i have 10 and in 2023 i have 10 so it should show 60 when i select 2023 in year slicer or if i select 2022 in slicer it should give me 50. It's not showing as of now. Please help me it's urgent. 

1 ACCEPTED SOLUTION
danextian
Super User
Super User

Hi @Anonymous ,

 

What  you're trying to achieive is not YTD but rather a cumulative count or sum. The concept of YTD is tha a calculation resets at every change of year (calendar or fiscal).  Try this instead:

 

 

cumulative =
CALCULATE (
    DISTINCTCOUNT ( 'table'[column] ),
    FILTER ( ALL ( 'table' ), 'table'[year] = MAX ( 'table'[year] ) )
)

 

the formula above assumes that you don't have  separate dates table and you're only calculating for the cumulative sum/count by  year and not for every date. 

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi !!
Thanks for your answer the same thing i applied and got the answers. But thanks for your time and efforts. Really Appreciate. 

danextian
Super User
Super User

Hi @Anonymous ,

 

What  you're trying to achieive is not YTD but rather a cumulative count or sum. The concept of YTD is tha a calculation resets at every change of year (calendar or fiscal).  Try this instead:

 

 

cumulative =
CALCULATE (
    DISTINCTCOUNT ( 'table'[column] ),
    FILTER ( ALL ( 'table' ), 'table'[year] = MAX ( 'table'[year] ) )
)

 

the formula above assumes that you don't have  separate dates table and you're only calculating for the cumulative sum/count by  year and not for every date. 

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.