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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
_-Christian-_
Frequent Visitor

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. 

_Christian__0-1713864318723.png

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

Can someone support me here? 


1 ACCEPTED SOLUTION
_-Christian-_
Frequent Visitor

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

View solution in original post

2 REPLIES 2
_-Christian-_
Frequent Visitor

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
lbendlin
Super User
Super User

May want to use DATEADD or EDATE instead,

 

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).

Do not include sensitive information or anything not related to the issue or question.

If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

Please show the expected outcome based on the sample data you provided.

Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.