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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
thhmez7
Helper III
Helper III

YTD Measure that calculates until today (not beyond)

Hello,

 

I need a YTD measure that calculates the revenue of a year only until the actual day (today) and not beyond if there are data.

My measure still calculates til end of year, whether it's displayed on a table or in a card.

 

In this example the measure's result should be 1.389.000, because today is Oct 29th and the last date with revenue is Oct 28th, given that I selected year 2020.

 

YTD til today.png

 

Thank you a lot!

1 ACCEPTED SOLUTION
v-luwang-msft
Community Support
Community Support

Hi @thhmez7 ,

When you use silcer ,slicer only filter the vusual ,and not work on the measure you created.

You could try the following measure:

Actual Revenue YTD3 = 
VAR day1 =
    DATE ( YEAR ( TODAY () ) - 1, MONTH ( TODAY () ), DAY ( TODAY () ) )
VAR v1 =
    CALCULATE (
        SUM ( Project[Actual Revenue] ),
        FILTER ( ALL ( 'Date' ), 'Date'[Date] <= day1 )
    )
RETURN
   IF(MAX(Project[date])<>BLANK(), IF (
        MAX ( 'Date'[Date] ) <= day1 ,
        CALCULATE (
            SUM ( Project[Actual Revenue] ),
            FILTER ( ALL ( 'Date' ), 'Date'[Date] <= MAX ( 'Date'[Date] ) )
        ),
        v1
    ),BLANK())

 

vluwangmsft_0-1635847091638.png

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


Best Regards

Lucien

View solution in original post

7 REPLIES 7
v-luwang-msft
Community Support
Community Support

Hi @thhmez7 ,

Has your problem been solved, if so, please consider Accept a correct reply as the solution or share your own solution to help others find it.

Best Regards
Lucien

Ashish_Mathur
Super User
Super User

Hi,

Ensure you have a Calendar Table with columns for Year, Month name and Month number.  Sort the Month Name by the Month number.  To your slicer, drag the Year from the Calendar Table.  To your visual, drag the Month name or date from the Calendar Table.  Write these measures:

Revenue = sum(project[actual revenue])

YTD revenue till date = calculate([revenue],datesbetween(calendar[date],minx(allexcept(calendar[year]),calendar[date]),today()))

Hope this helps. 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-luwang-msft
Community Support
Community Support

Hi @thhmez7 ,

When you use silcer ,slicer only filter the vusual ,and not work on the measure you created.

You could try the following measure:

Actual Revenue YTD3 = 
VAR day1 =
    DATE ( YEAR ( TODAY () ) - 1, MONTH ( TODAY () ), DAY ( TODAY () ) )
VAR v1 =
    CALCULATE (
        SUM ( Project[Actual Revenue] ),
        FILTER ( ALL ( 'Date' ), 'Date'[Date] <= day1 )
    )
RETURN
   IF(MAX(Project[date])<>BLANK(), IF (
        MAX ( 'Date'[Date] ) <= day1 ,
        CALCULATE (
            SUM ( Project[Actual Revenue] ),
            FILTER ( ALL ( 'Date' ), 'Date'[Date] <= MAX ( 'Date'[Date] ) )
        ),
        v1
    ),BLANK())

 

vluwangmsft_0-1635847091638.png

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


Best Regards

Lucien

Hi Thank you for replicating this case. I tried your calculation. But still doesn't show the result of yours. Can you look into it?

YTD til today2.png

Hi @thhmez7 ,

The following is relationship in  my case .

vluwangmsft_0-1635901584593.png

And could you pls share your pbix file through a public link  that I could test on your sample? Remember to remove confidential data.

 


Best Regards

Lucien

amitchandak
Super User
Super User

@thhmez7 , Try like these with help from date tbale

 

YTD Corrected =
var _max = format(today(),"MMDD")
return
calculate(Sum('order'[Qty]),DATESYTD('Date'[Date]),format('Date'[Date],"MMDD")<=_max)


LYTD Corrected =
var _max = format(today(),"MMDD")
return
calculate(Sum('order'[Qty]),DATESYTD(dateadd('Date'[Date],-1,year)),format('Date'[Date],"MMDD")<=_max)

 

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here
Nicole_PBI
Frequent Visitor

Have a look at this post: TOTALYTD until TODAY .

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.