Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Add a year variable to a datesbetween

Hi Power Bi Community !    I'd need your help to perform the following calculation :  I'd like to be able to have the amount of sales between two dates, and in the formula, the days and months wou...
  • ryan_mayu's avatar
    5 years ago

    Anonymous 

    you can have a try, the selectedyear returns True or False, not a year value. you can try below DAX.

    Measure = 
    VAR selectedyear=if(HASONEVALUE('Table'[year].[Year]),max('Table'[year]),blank())
    return CALCULATE(sum('Table'[amount]),DATESBETWEEN('Table'[year],date(year(selectedyear),1,1),date(year(selectedyear),9,30)))