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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Average of certain Years

Hi,

I have this table

11.jpg

 

 

I need a Calculated Column in another table wich has Unique Branch values. This Column needs to show the average of the last 2 yeas ( Average of the SUM of score for each team based on year 3 and 4)

22.jpg

 

 

Thanks for your help!

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

Hi @Anonymous ,

 

We can create a calculate column to meet your requirement.

 

Column = 
VAR _max =
    CALCULATE (
        MAX ( 'Table'[Year] ),
        FILTER ( 'Table', 'Table'[Branch] = 'Table (2)'[Branch] )
    )
VAR _min = _max - 1
VAR _sum_max =
    CALCULATE (
        SUM ( 'Table'[Score] ),
        FILTER (
            'Table',
            'Table'[Year] = _max
                && 'Table'[Branch] = 'Table (2)'[Branch]
        )
    )
VAR _sum_min =
    CALCULATE (
        SUM ( 'Table'[Score] ),
        FILTER (
            'Table',
            'Table'[Year] = _min
                && 'Table'[Branch] = 'Table (2)'[Branch]
        )
    )
RETURN
    DIVIDE ( _sum_max + _sum_min, 2 )

 

AV1.jpg

 

If you have any question, please kindly ask here and we will try to resolve it.

BTW, pbix as attached.

 

Best regards,

 

Community Support Team _ zhenbw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-zhenbw-msft
Community Support
Community Support

Hi @Anonymous ,

 

How about the result after you follow the suggestions mentioned in my original post?

Could you please provide more details or expected result about it If it doesn't meet your requirement?

If you've fixed the issue on your own please kindly share your solution.

If the above posts help, please kindly mark it as a solution to help others find it more quickly. Thanks!

 

Best regards,

 

Community Support Team _ zhenbw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

v-zhenbw-msft
Community Support
Community Support

Hi @Anonymous ,

 

We can create a calculate column to meet your requirement.

 

Column = 
VAR _max =
    CALCULATE (
        MAX ( 'Table'[Year] ),
        FILTER ( 'Table', 'Table'[Branch] = 'Table (2)'[Branch] )
    )
VAR _min = _max - 1
VAR _sum_max =
    CALCULATE (
        SUM ( 'Table'[Score] ),
        FILTER (
            'Table',
            'Table'[Year] = _max
                && 'Table'[Branch] = 'Table (2)'[Branch]
        )
    )
VAR _sum_min =
    CALCULATE (
        SUM ( 'Table'[Score] ),
        FILTER (
            'Table',
            'Table'[Year] = _min
                && 'Table'[Branch] = 'Table (2)'[Branch]
        )
    )
RETURN
    DIVIDE ( _sum_max + _sum_min, 2 )

 

AV1.jpg

 

If you have any question, please kindly ask here and we will try to resolve it.

BTW, pbix as attached.

 

Best regards,

 

Community Support Team _ zhenbw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

ryan_mayu
Super User
Super User

@Anonymous 

please try this

newtable = 
VAR maxyear=max('Table (2)'[year])
return SUMMARIZE(FILTER('Table (2)','Table (2)'[year]>=maxyear-1),'Table (2)'[branch],"AVG",AVERAGE('Table (2)'[score]))

1.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Ashish_Mathur
Super User
Super User

Hi,

Why do you need a calculated column formula?  Why not a measure in a Table visual?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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