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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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