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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
yaman123
Post Partisan
Post Partisan

YTD Volume

Hi, 

 

I am having an issue calculating the YTD volume from a dataset. 

 

I have a supply end date date slicer which is a between e.g user selects 01/02/2021 - 28/02/2021

 

I need to calculate the YTD Volume from the chosen date period. 

 

Below is an example of the YTD data if 01/02/2021 - 28/02/2021 is selected. 

 

Capture.PNG

 

TIA

5 REPLIES 5
v-xulin-mstf
Community Support
Community Support

Hi @yaman123

 

Create Date_slicer table as:

Date Slicer = 
CALENDAR(MIN('Table'[SUPPLY_END_DATE]),MAX('Table'[SUPPLY_END_DATE]))

Try measure as:

Measure = 
var min_date=
EOMONTH(MINX('Date Slicer',SELECTEDVALUE('Date Slicer'[Date],MAX('Date Slicer'[Date]))),-11)
var max_date=
MINX('Date Slicer',SELECTEDVALUE('Date Slicer'[Date],MAX('Date Slicer'[Date])))
return 
CALCULATE(
    MAX('Table'[COLLECTION_LITRES]),
    FILTER(
        ('Table'),
        'Table'[SUPPLY_END_DATE]<=max_date && 'Table'[SUPPLY_END_DATE]>=min_date 
    )
)

Here is the output:

v-xulin-mstf_0-1620199883171.png

The pbix file is attached.

 

Best Regards,
Link

 

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

amitchandak
Super User
Super User

@yaman123 , YTD will be from the start of the year

 

This seems like sum(Table[collection_liter])

 

YTD with help from date table

calculation(sum(Table[collection_liter]) ,datesytd('Date'[Date]) )

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi, 

 

I need the YTD to be -11 months from the chosen dates. How can this be done? 

@yaman123 , Try like

 

Rolling 11 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-11,MONTH))

 

or

 

measure =
var _max = maxx(allselected('Date1'), 'Date1'[Date])
var _min = eomonth(minx(all('Date'), 'Date'[Date]),-11)
return
calculate(sum(Sales[Sales Amount]), filter(all('Date'),'Date'[Date] <= _max && 'Date'[Date] >=_min))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi, 

 

That also doesnt work. My slicer is is a between selection, so two dates are selected. I am not getting the correct figures from the code you have provided. 

Helpful resources

Announcements
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.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 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.