Forum Discussion

_-Christian-_'s avatar
_-Christian-_
Frequent Visitor
2 years ago
Solved

Sameperiodlastyear() and month filter

Hello,

I want to make a forecast with values from the last year, if the sixth month of the forecast is startet. 

I try the following Dax formula: 

var Cost = Calculate(
        sum(Table[Cost]),
        USERELATIONSHIP('Calendar'[Date],'Table'[Close Date]),
        SAMEPERIODLASTYEAR('Calendar'[Date]),
        Filter('Calendar'[Date], 
'Calendar'[Date]>TODAY()+366/2)
        )


I recieve the following output. 

It look likes that the filterfunction doesn't work here. The first entry should be in September. 

Can someone support me here? 


  • Thanks for your reply!

     I figured out a solution for the problem. Instead of using today() in the filter context, I create a new variable. I cannot explain why it works now, but it works.

    var today_ = today() -366/2

    var Cost = Calculate(
            sum(Table[Cost]),
            USERELATIONSHIP('Calendar'[Date],'Table'[Close Date]),
            SAMEPERIODLASTYEAR('Calendar'[Date]),
            Filter('Calendar'[Date], 
    'Calendar'[Date]> today_)
            )

    return 
    Cost

2 Replies