Forum Discussion

Metricbits's avatar
Metricbits
Frequent Visitor
5 years ago
Solved

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...
  • v-robertq-msft's avatar
    5 years ago

    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:

     

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

     

    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:

     

    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.