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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
Sept PBI Carousel

Power BI Monthly Update - September 2024

Check out the September 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

Find out what's new and trending in the Fabric Community.