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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
bettysmile
Regular Visitor

calculate Date filter SAMEPERIODLASTYEAR

Hello,

 

i have a calculate Date filter like this:

VAR Last month =   SELECTCOLUMNS(ADDCOLUMNS( CALCULATETABLE(
                    'Datum (D)', FILTER(ALLNOBLANKROW('Datum (D)'[Datum]), YEAR('Datum (D)'[Datum]) = YEAR(TODAY()) &&    MONTH('Datum (D)'[Datum])+1 = MONTH(TODAY())
                    )        ),  "Datebe","Last month"
            ), "Datebe",[Datebe], "Datum",'Datum (D)'[Datum], "Sort",21   )    
 
i have this filter for "last week", "last month", "last fincal year" (not calendar year).
 
Now i want to combine it with the function SAMEPERIODLASTYEAR:
 
CALCULATE(
    SUM('ABC)'[hourspertime]),  
    SAMEPERIODLASTYEAR(Datebe[Datum])          
)
 
but it doesn't work - have you an idea why?
Thank you
1 REPLY 1
KVRKarthik
Frequent Visitor

Hi,

In the variable "Last Month", the table calculation is

CALCULATETABLE(
                    'Datum (D)', FILTER(ALLNOBLANKROW('Datum (D)'[Datum]), YEAR('Datum (D)'[Datum]) = YEAR(TODAY()) &&    MONTH('Datum (D)'[Datum])+1 = MONTH(TODAY())
 
As per this function, if MONTH(TODAY()) = "August" and YEAR(TODAY()) = 2023 then the Datebe[Datum] will have dates of 2023 and July Month.
When the calculation is limited to current year and current year's previous month then this table cannot support you to navigate to same period last year.
If you need to execute SAMEPERIODLASTYEAR in your presentation then please revise your filtering conditions in a new measure as  
YEAR('Datum (D)'[Datum]) = YEAR(TODAY()) - 1 &&    MONTH('Datum (D)'[Datum])+1 = MONTH(TODAY())
Hope this helps in resolving your issue.
Regards,
Karthik.
 
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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