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
Anonymous
Not applicable

YTD returning blank in card visual

Hello - I am using the QTD measure below and it works fine.  

 

However, the YTD measure just returns a blank value.   I know there are various ways to calculate YTD, but  I am trying to standardized my formulaes and I like this formula because it hides future dates with no values.    Any idea why the YTD is returning blank...and how to fix it but still maintaining this general formula structure.  

 

YTD Orders  = CALCULATE(SUM('Orders 2'[Net Price]), FILTER('Date Table', 'Date Table'[Date] >= DATE(YEAR(TODAY()), YEAR(TODAY()), 01)), FILTER('Date Table', 'Date Table'[Date] <= TODAY()))
 
QTD Orders  = CALCULATE(SUM('Orders 2'[Net Price]), FILTER('Date Table', 'Date Table'[Date] >= DATE(YEAR(TODAY()), QUARTER(TODAY()), 01)), FILTER('Date Table', 'Date Table'[Date] <= TODAY()))
1 ACCEPTED SOLUTION
v-deddai1-msft
Community Support
Community Support

Hi @Anonymous ,

 

You can use the following two measure:

 

YTD Orders  = CALCULATE(SUM('Orders 2'[Net Price]), FILTER('Date Table', 'Date Table'[Date] >= DATE(YEAR(TODAY()), MONTH(TODAY()), 1)), FILTER('Date Table', 'Date Table'[Date] <= TODAY()))

QTD Orders  = CALCULATE(SUM('Orders 2'[Net Price]), FILTER('Date Table', 'Date Table'[Date] >= DATE ( YEAR (TODAY()), ROUNDUP(DIVIDE(MONTH(TODAY()),3 ),0 ) *3 -2, 1)), FILTER('Date Table', 'Date Table'[Date] <= TODAY()))

 

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

 

Best Regards,

Dedmon Dai

View solution in original post

5 REPLIES 5
v-deddai1-msft
Community Support
Community Support

Hi @Anonymous ,

 

You can use the following two measure:

 

YTD Orders  = CALCULATE(SUM('Orders 2'[Net Price]), FILTER('Date Table', 'Date Table'[Date] >= DATE(YEAR(TODAY()), MONTH(TODAY()), 1)), FILTER('Date Table', 'Date Table'[Date] <= TODAY()))

QTD Orders  = CALCULATE(SUM('Orders 2'[Net Price]), FILTER('Date Table', 'Date Table'[Date] >= DATE ( YEAR (TODAY()), ROUNDUP(DIVIDE(MONTH(TODAY()),3 ),0 ) *3 -2, 1)), FILTER('Date Table', 'Date Table'[Date] <= TODAY()))

 

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

 

Best Regards,

Dedmon Dai

@v-deddai1-msft , how would one represent MTD? 

stevedep
Memorable Member
Memorable Member

Anonymous
Not applicable

@stevedep  Thanks Steve.  I tried that and for some reason it still returns blank.   But I see in the DAX editor you got it to work for you.  Not sure why it is not on my data set.    I can of course just use a sum of total measure which works just fine.    But my original intention was to try and stay with the same formula structure that I am using in the MTD and QTD measures as I referenced above.   I thought by just replacing "Quarter" with "Year" it would work, but it does not.  

amitchandak
Super User
Super User

@Anonymous , Try to use time intelligence

 

QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(('Date'[Date])))

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"12/31"))

 

YTD QTY forced=
var _max = today()
return
if(max('Date'[Date])<=_max, calculate(Sum('order'[Qty]),DATESYTD('Date'[Date])), blank())
//or
//calculate(Sum('order'[Qty]),DATESYTD('Date'[Date]),filter('Date','Date'[Date]<=_max))
//calculate(TOTALYTD(Sum('order'[Qty]),'Date'[Date]),filter('Date','Date'[Date]<=_max))

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.