Forum Discussion

JWT's avatar
JWT
Frequent Visitor
4 years ago
Solved

Last Year Year To Date summarized

Hi, I am new to Power BI and struggling my way to find a way to calculate a total amount of sales YTD last year. I have a table containing sales and dates (incomplete) and another table containing ...
  • v-kkf-msft's avatar
    v-kkf-msft
    4 years ago

    Hi JWT ,

     

    Please try the following formula:

     

    Sales YTD LY =
    IF (
        HASONEVALUE ( Periode[Måned] ),
        IF (
            [Sales YTD] <> BLANK (),
            CALCULATE ( [Total Sales], SAMEPERIODLASTYEAR ( Periode[Dato] ) )
        ),
        CALCULATE (
            [Total Sales],
            DATESBETWEEN (
                Periode[Dato],
                EDATE ( MIN ( Periode[Dato] ), -12 ),
                EOMONTH ( MAX ( Sales[Date] ), -12 )
            )
        )
    )
    

     

    If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
    Best Regards,
    Winniz
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.