Forum Discussion

lennyt99's avatar
lennyt99
Helper I
3 years ago

return last years DTD...

I need help bringing back lY DTD please!! 

 

My DTD measure is correct and working and is as follows: 

 

LY DTD =
IF (
HASONEVALUE ( 'Fiscal Year Conversion'[Fiscal Year] ),
CALCULATE (
SUM ( 'Opportunity Tracker 2.0'[Annual Volume LBS] ),
FILTER (
ALL ( 'Fiscal Year Conversion' ),
'Fiscal Year Conversion'[Fiscal Year] = VALUES ('Fiscal Year Conversion'[Fiscal Year] )
&& 'Fiscal Year Conversion'[Calendar Date] <= MAX ('Fiscal Year Conversion'[Calendar Date] )
)
),
BLANK ()
)

 

As for my LY DTD I am doing (just putting -1 after fy): 

LY DTD =
IF (
HASONEVALUE ( 'Fiscal Year Conversion'[Fiscal Year] ),
CALCULATE (
SUM ( 'Opportunity Tracker 2.0'[Annual Volume LBS] ),
FILTER (
ALL ( 'Fiscal Year Conversion' ),
'Fiscal Year Conversion'[Fiscal Year] = VALUES ('Fiscal Year Conversion'[Fiscal Year] ) -1
&& 'Fiscal Year Conversion'[Calendar Date] <= MAX ('Fiscal Year Conversion'[Calendar Date] )
)
),
BLANK ()
)
 
any suggestions?? It shouldn't even return until January 2nd of FY2020, as January 2nd of 2019 was my first date. 

Thanks!

2 Replies

  • daXtreme's avatar
    daXtreme
    Solution Sage

    If you want to calculate LY DTD, you first have to calculate the date range for DTD and then move this range one year back and apply this filter to the measure in question.

     

    By the way, it's a DAX question, not Power Query, so technically you should have asked this question on a different forum.

     

  • v-yalanwu-msft's avatar
    v-yalanwu-msft
    Community Support

    Hi, lennyt99 ;

    Try it .

    LY DTD =
    IF (
        HASONEVALUE ( 'Fiscal Year Conversion'[Fiscal Year] ),
        CALCULATE (
            SUM ( 'Opportunity Tracker 2.0'[Annual Volume LBS] ),
            FILTER (
                ALL ( 'Fiscal Year Conversion' ),
                'Fiscal Year Conversion'[Fiscal Year]
                    = MAX ( 'Fiscal Year Conversion'[Fiscal Year] ) - 1
                    && 'Fiscal Year Conversion'[Calendar Date]
                        <= MAX ( 'Fiscal Year Conversion'[Calendar Date] )
            )
        ),
        BLANK ()
    )
    

    If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

    Solved: How to upload PBI in Community - Microsoft Power BI Community


    Best Regards,
    Community Support Team _ Yalan Wu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.