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

The FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now

Reply
ade_kurniawan
Frequent Visitor

How to get average gap through filter

Dear friends,

 

i want to get gap from average score from all year data, but the data can't read because my slicer require single selection of year.

ade_kurniawan_0-1646983285587.png

Score 2021 = 5.00
Score 2020 = 3.50
the gap score i want to show is 1.50, but if year select is 2021, 2020 data will not be calculated.

here is the pbix file : https://drive.google.com/file/d/10Gpy0UJmCDTovC8NJ25OtS5divb-QDmq/view?usp=sharing

Thanks for help

1 ACCEPTED SOLUTION
v-cazheng-msft
Community Support
Community Support

Hi @ade_kurniawan ,

 

You need make a little bit change to your Gap score Measure.

Gap score =
VAR selectedYear =
    MAX ( Sheet1[Year] )
VAR CurrentScore =
    CALCULATE (
        [avg score],
        FILTER ( ALL ( Sheet1 ), Sheet1[Year] = selectedYear )
    )
VAR LastScore =
    CALCULATE (
        [avg score],
        FILTER ( ALL ( Sheet1 ), Sheet1[Year] = MAX ( Sheet1[Year] ) - 1 )
    )
RETURN
    CurrentScore - LastScore

 

Then, the result should look like this.

vcazhengmsft_0-1647324425695.png

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let me know. Thanks a lot!

 

Best Regards,

Community Support Team _ Caiyun

View solution in original post

3 REPLIES 3
v-cazheng-msft
Community Support
Community Support

Hi @ade_kurniawan ,

 

You need make a little bit change to your Gap score Measure.

Gap score =
VAR selectedYear =
    MAX ( Sheet1[Year] )
VAR CurrentScore =
    CALCULATE (
        [avg score],
        FILTER ( ALL ( Sheet1 ), Sheet1[Year] = selectedYear )
    )
VAR LastScore =
    CALCULATE (
        [avg score],
        FILTER ( ALL ( Sheet1 ), Sheet1[Year] = MAX ( Sheet1[Year] ) - 1 )
    )
RETURN
    CurrentScore - LastScore

 

Then, the result should look like this.

vcazhengmsft_0-1647324425695.png

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let me know. Thanks a lot!

 

Best Regards,

Community Support Team _ Caiyun

thank you so much

amitchandak
Super User
Super User

@ade_kurniawan , in such cases, it is best to have the date/year come from a separatetable. joined to your table

 

Last year avg  =

Calculate([Avg Score], filter(All(Date[Year]), Date[Year] = max(Date[Year])-1))

 

diff =

[Avg Score] - [Last year avg]

 

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.