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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
RodrigoZD
Frequent Visitor

YOY week number

I would like to calculate a difference in averages if certain conditions are met:

 

In this particular example, my data looks something like this:

 

 

RawData.PNG

Then, when I group it by average of conditions (Year and WeekNumber), it looks something like this:Table.PNG

And finally, what I want to do, is to do an average when Year = Year -1 and week number is the same, so I would have something like this:Output.PNG

My approach was to create a formula that was something like:

 

Delta = CALCULATE ( AVERAGE ( Table[Ratio] ),
                                    FILTER( 
                                                 ALL ( Table ),
                                                 Table[Year] = Table[Year] - 1
                                                 && Table[WeekNumber] = Table[WeekNumber]
                                    )
               )
              // I know the WeekNumber = WeekNumber part is wrong since it's like 1=1, but 
             // I would like to know if there is a way to do something similar to this
1 ACCEPTED SOLUTION
RodrigoZD
Frequent Visitor

For those of you who could have the same question, I found a solution creating a measure like this:

 

DeltaTest = 
            CALCULATE(AVERAGE(Table[Ratio]),
            FILTER(
                    ALL(Table),
                    Table[WeekNumber] = SELECTEDVALUE(Table[WeekNumber]) && Table[Year] = SELECTEDVALUE(Table[Year])-1)
            )

and then just another measure that substract

Delta = Table[Ratio] - DeltaTest

View solution in original post

1 REPLY 1
RodrigoZD
Frequent Visitor

For those of you who could have the same question, I found a solution creating a measure like this:

 

DeltaTest = 
            CALCULATE(AVERAGE(Table[Ratio]),
            FILTER(
                    ALL(Table),
                    Table[WeekNumber] = SELECTEDVALUE(Table[WeekNumber]) && Table[Year] = SELECTEDVALUE(Table[Year])-1)
            )

and then just another measure that substract

Delta = Table[Ratio] - DeltaTest

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors