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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Gregs138
Helper I
Helper I

DAX TOTAL YTD problem

Hi there, trying to solve what should seem like a fairly straightforward reporting/visual problem.  I am trying to compare LY Total Sales to CY Total Sales using a line chart by month

 

The problem is that when I use am expression like this:

 

Example1:

YTD Sales = TOTALYTD('fact'[Total Sales],'DateDimension'[Date])

I get blank results.

 

Oddly if I use :

Example 2

YTD Sales = TOTALYTD('fact'[Total Sales], 'fact'[DateOfSale])

 

I get what appear to be good result for CY, but some rason now LY has a big gap in it. 

 

 

My model is pretty standard with a one to many dimDate ->facttable design joined on date.  Every example I have looked at seems to say my first example is correct, however it does not work at all.  The second example, I typically don't do and would expect it to be a little odd anyway, but not sure why example one is not working.  I have done this type of YTD expression before and I feel it might be something else besides the expression, maybe a relationship, data type, some other issue.  Could be I am just really tired lol.  But I should be able to name the Date field from the Date dimension and this would work.  I have never had to call the date field from the fact table itself.

 

Anyway any feedback or advice would be great.  Been banging my head against this one all day and not sure what I am doing wrong or what setting I might be missing.  TY!

 

 

Results of Example 1 expression( YTD TOTAL is completely missing)

YTD Sales = TOTALYTD('fact'[Total Sales],'DateDimension'[Date])

 

YTD completely missingYTD completely missing

 

Example 2

YTD Sales = TOTALYTD('fact'[Total Sales], 'fact'[DateOfSale])

LY vs YTD.JPG

2 ACCEPTED SOLUTIONS
Gregs138
Helper I
Helper I

Just some follow up on this for anyone that is having the same problem.

 

The solution ended up being to add a filter to the YTD() function.  It is stated that it is an optional filter, however it seems to be rather necessary or else your YTDTotal will carry the last total(today) until the end of the year.  This is a little buggy imo but manageble with the custom filter parameter.

 

Here was my fix:

 

YTD Sales = TOTALYTD(SUM(SalesTable[SalesAmount]),'Order Date'[Date],filter('Order Date',[Date] < NOW()))

View solution in original post


@Gregs138 wrote:

Just some follow up on this for anyone that is having the same problem.

 

The solution ended up being to add a filter to the YTD() function.  It is stated that it is an optional filter, however it seems to be rather necessary or else your YTDTotal will carry the last total(today) until the end of the year.  This is a little buggy imo but manageble with the custom filter parameter.

 

Here was my fix:

 

YTD Sales = TOTALYTD(SUM(SalesTable[SalesAmount]),'Order Date'[Date],filter('Order Date',[Date] < NOW()))


@Gregs138

Thanks for your sharing. You can mark your reply as solution to close this thread. People who may have the same question can benefit from the solution.

View solution in original post

3 REPLIES 3
Gregs138
Helper I
Helper I

Just some follow up on this for anyone that is having the same problem.

 

The solution ended up being to add a filter to the YTD() function.  It is stated that it is an optional filter, however it seems to be rather necessary or else your YTDTotal will carry the last total(today) until the end of the year.  This is a little buggy imo but manageble with the custom filter parameter.

 

Here was my fix:

 

YTD Sales = TOTALYTD(SUM(SalesTable[SalesAmount]),'Order Date'[Date],filter('Order Date',[Date] < NOW()))


@Gregs138 wrote:

Just some follow up on this for anyone that is having the same problem.

 

The solution ended up being to add a filter to the YTD() function.  It is stated that it is an optional filter, however it seems to be rather necessary or else your YTDTotal will carry the last total(today) until the end of the year.  This is a little buggy imo but manageble with the custom filter parameter.

 

Here was my fix:

 

YTD Sales = TOTALYTD(SUM(SalesTable[SalesAmount]),'Order Date'[Date],filter('Order Date',[Date] < NOW()))


@Gregs138

Thanks for your sharing. You can mark your reply as solution to close this thread. People who may have the same question can benefit from the solution.

Anonymous
Not applicable

I am don't understand why it is nesessary to use another dateset (Order Date[Date]) in the TotalYTD formula? Why can't you use the date column in your Sales Table? I have highlighted this below and would appreciate if you can share your knowlege:

 

TOTALYTD(SUM(SalesTable[SalesAmount]),'Order Date'[Date]

 

Tnx

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Kudoed Authors