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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Metricbits
Frequent Visitor

DATESYTD - use variable for year end date

Hi,

 

Does anyone know if I can somehow use the parameter for the year-end date? I would like "06-30" in below formula to be replaced with a parameter

 

 

 

 

Act GC YTD = CALCULATE (
    SUM ( 'General Ledger'[GrossAmt_GC] ),
    ALL ( 'Calendar' ),
    DATESYTD ( 'Calendar'[Date] , "06-30")
)

 

 

 

 

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

Hi, @Metricbits 

According to your description, I guess that you want to create a slicer to get the end date and calculate the sum of [GrossAmt_GC] based on the end date dynamically, right? I think you can try this method to achieve this:

This is part of my test data based on your DAX formula:

v-robertq-msft_0-1618825550636.png

 

  1. I create a calendar table and avoid the relationship between the main table with it:

v-robertq-msft_1-1618825550637.png

 

  1. I created a measure like this:

 

Act GC YTD =

var _year=YEAR(TODAY())

var _month=MONTH(MIN('Calendar'[Date]))

var _day=DAY(MIN('Calendar'[Date]))

return

CALCULATE(

    SUM('General Ledger'[GrossAmt_GC]),

FILTER(ALL('General Ledger'),[Date]>=DATE(_year,1,1)&&[Date]<=DATE(_year,_month,_day)))

 

  1. I create a Month-day slicer and a card chart to place this measure:

v-robertq-msft_2-1618825550643.png

 

And you can get what you want.

You can download my test pbix file below

 

If this result is not what you want, you can post some sample data(without sensitive data) and your expected result.

How to Get Your Question Answered Quickly 

Thank you very much!

 

Best Regards,

Community Support Team _Robert Qin

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

View solution in original post

4 REPLIES 4
v-robertq-msft
Community Support
Community Support

Hi, @Metricbits 

According to your description, I guess that you want to create a slicer to get the end date and calculate the sum of [GrossAmt_GC] based on the end date dynamically, right? I think you can try this method to achieve this:

This is part of my test data based on your DAX formula:

v-robertq-msft_0-1618825550636.png

 

  1. I create a calendar table and avoid the relationship between the main table with it:

v-robertq-msft_1-1618825550637.png

 

  1. I created a measure like this:

 

Act GC YTD =

var _year=YEAR(TODAY())

var _month=MONTH(MIN('Calendar'[Date]))

var _day=DAY(MIN('Calendar'[Date]))

return

CALCULATE(

    SUM('General Ledger'[GrossAmt_GC]),

FILTER(ALL('General Ledger'),[Date]>=DATE(_year,1,1)&&[Date]<=DATE(_year,_month,_day)))

 

  1. I create a Month-day slicer and a card chart to place this measure:

v-robertq-msft_2-1618825550643.png

 

And you can get what you want.

You can download my test pbix file below

 

If this result is not what you want, you can post some sample data(without sensitive data) and your expected result.

How to Get Your Question Answered Quickly 

Thank you very much!

 

Best Regards,

Community Support Team _Robert Qin

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

mahoneypat
Microsoft Employee
Microsoft Employee

Can you explain further what you are trying to accomplish?  Parameters are used in the query editor (What If Parameters on the DAX side).  If you want users to be able to dynamically select which year end to use, you could add a disconnected table with a text column (for the slicer) and a numeric or date column to be used in a Measure to dynamically adjust results based on the selected year end.

 

Regards,

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Yes, this is exactly what I am trying to do. I a nutshell, I am building a template that will be used by multiple orgs. They have different FY end dates. But when I try to put a reference to a table or column in this formula (DATESYTD), it PBI doesn't accept it. 

@Metricbits , i have the exact same requirement.. Were u able to achieve it ? Please share the outcome

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors