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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
smeg
Helper I
Helper I

how to get 52 weeks/YAGO data using DAX

Hi I have below measure which is working perfectly fine and giving expected results.

 

12wks Dollars:=CALCULATE([Dollars],FILTER(Metrics_Table, Metrics_Table[Agg_Level]= 12))

 

But when I try to write below measure  12wks Dollars year ago it is throwing an error,

 

12wks Dollars YAGO:=CALCULATE([Dollars],FILTER(Metrics_Table, Metrics_Table[Agg_Level]= 12 &                                        Metrics_Table[AO_Date]=dateadd(Metrics_Table[AO_Date],-364,Day)))

 

smeg_1-1688008669116.png

 

 

Also I have dates_table too with Date_Anchor_YAgo field(exactly 52 weeks back date  as shown below,

smeg_4-1688009692145.png

 

Metric table and date table are both having relationship.

 

smeg_3-1688009353997.png

 

If it is better to  use Date_Anchor_YAgo field from dates table ,how can i write my 12wks Dollars YAGO measure correctly?

 

Thanks..

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @smeg,

You can try to use the following measure formula if it works on your side: (I modify the DATEADD function to use with extracted calendar date values as condition in formula calculations)

12wks Dollars YAGO :=
VAR currDate =
    MAX ( Calendar[Date] )
RETURN
    CALCULATE (
        [Dollars],
        FILTER (
            ALLSELECTED ( Metrics_Table ),
            Metrics_Table[Agg_Level] = 12 & Metrics_Table[AO_Date]
                = DATE ( YEAR ( currDate ) - 1, MONTH ( currDate ), DAY ( currDate ) )
        )
    )

Regards,

Xiaoxin Sheng

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @smeg,

You can try to use the following measure formula if it works on your side: (I modify the DATEADD function to use with extracted calendar date values as condition in formula calculations)

12wks Dollars YAGO :=
VAR currDate =
    MAX ( Calendar[Date] )
RETURN
    CALCULATE (
        [Dollars],
        FILTER (
            ALLSELECTED ( Metrics_Table ),
            Metrics_Table[Agg_Level] = 12 & Metrics_Table[AO_Date]
                = DATE ( YEAR ( currDate ) - 1, MONTH ( currDate ), DAY ( currDate ) )
        )
    )

Regards,

Xiaoxin Sheng

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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