Forum Discussion
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")
)
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:
- I create a calendar table and avoid the relationship between the main table with it:
- 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)))- I create a Month-day slicer and a card chart to place this measure:
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.
4 Replies
- mahoneypat
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
- MetricbitsFrequent Visitor
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.
- ak77
Post Patron
Metricbits , i have the exact same requirement.. Were u able to achieve it ? Please share the outcome
- v-robertq-msft
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:
- I create a calendar table and avoid the relationship between the main table with it:
- 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)))- I create a Month-day slicer and a card chart to place this measure:
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.