Forum Discussion

fcb2026's avatar
fcb2026
Frequent Visitor
3 months ago
Solved

Issue with SAMEPERIODLASTYEAR and Manual Time Intelligence

Hi,

the visual on the right works as expected, as it uses built-in time intelligence and automatic date handling.

However, I would like to use the visual on the left without automatic time intelligence.

In this case, the posting date 02.05.2025 is mapped incorrectly โ€” it should be assigned to WD 1, but currently isnโ€™t.

How can I achieve the correct mapping while staying without automatic time intelligence?



Measure for the right one:



Current measure for the left one:

CALCULATE(
    SALES[0C SALES],
    SAMEPERIODLASTYEAR('DATE'[Date])
)

My calendar table is already configured with WD_Running_Total = 1 for 02.05.2025.

 

Thanks a lot for your support!

Best regards

 

 

  • Hi fcb2026,

    Thank you Ashish_Mathur Natarajan_M johnt75, for your insights.

    I was able to reproduce the issue in the PBIX file you provided.

    The problem occurs because the current PY measure relies on DATEADD() or SAMEPERIODLASTYEAR(), which compare exact calendar dates rather than using the custom WD_Running_Total (working-day sequence) logic.

     

    Thank you.

  • You need to separate the working days from the date dimension. Create a new table like

    Working Day = SELECTCOLUMNS(
        GENERATESERIES( 1, 23 ),
        "Working Day", [Value] 
    )

    Create a one-to-many relationship from this new table to your Date table. Use the column from this table in your visuals, and change your PY measure to

    PY = 
    VAR _CurrentYear =
        CALCULATE(
            MAX( 'DATE'[Year] ),
            REMOVEFILTERS( 'Working Day' )
        )
    VAR _CurrentMonth =
        CALCULATE(
            MAX( 'DATE'[Period] ),
            REMOVEFILTERS( 'Working Day' )
        )
    VAR _CurrentWD = VALUES( 'Working Day'[Working Day] )
    RETURN
        CALCULATE(
            SUM( SALES_TABLE[Sales] ),
            REMOVEFILTERS( 'DATE' ),
            _CurrentWD,
            'DATE'[Year] = _CurrentYear - 1,
            'DATE'[Period] = _CurrentMonth
        )

    See attached PBIX for sample.

23 Replies

  • Try marking the Date table as a date table, then the SAMEPERIODLASTYEAR should work I think.

  • fcb2026's avatar
    fcb2026
    Frequent Visitor

    already done, but it doesn't work with the like for like comparison ๐Ÿ˜ž

     

    02.05.2025 is a friday, 04.05.2025 is a sunday. Both sales should be mapped to WD 1 in prior year = 2025

  • Hi fcb2026 ,The first change you can make is to mark the date table as a calendar table and set the appropriate grain. Ensure that the dates are continuous. If this does not resolve the issue, please share the PBIX file so we can provide better assistance.

    Thanks!

    Natarajan Manivasagan

    If you found this helpful, please consider giving it a Kudos and marking it as the accepted solution โ€” it goes a long way in helping others facing the same issue.

     

    ๐Ÿ† Best Solution for Enterprise BI โ€” 2026 Microsoft Fabric Semantic Link Developer Experience Challenge
    ๐Ÿ‘‰ Microsoft announcement ยท View the winning notebook

     

    For more Power BI tips and discussions, let's connect on LinkedIn.

     

    Cheers!