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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Average of sum of total dynamically

Hi,

 

I have the matrix below:

I need to create a measure that average the line Total dyamically. (I will use this measure as a line over bar chart)

 

For example. sum all the totals and divide by the numbers of years that I want (i.e sum from 2010 to 2015 and divide by 5 or sum the totals from 2010 to 2012 and divide by 2)

 

Is this possible creating some parameter?

fabnishi1207_0-1617162837721.png

 

Thank you

 

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

Hi  @Anonymous ,

 

First create a parameter table as below,which is for dynamic selection:

Slicer table = GENERATESERIES(1,12,1)

Then create  a  measure as below:

Measure = IF(
    NOT(ISFILTERED('Slicer table'[Value])),CALCULATE(SUM('Table'[Value])),
    IF(ISINSCOPE('Table'[Country]),CALCULATE(SUM('Table'[Value])),
 var _sum=CALCULATE(SUM('Table'[Value]),FILTER(ALL('Table'),'Table'[Year]>=MAX('Table'[Year])-SELECTEDVALUE('Slicer table'[Value])&&'Table'[Year]<=MAX('Table'[Year])))
 Return
 DIVIDE(_sum,SELECTEDVALUE('Slicer table'[Value]))))

And you will see:

v-kelly-msft_0-1617348342611.png

For the related .pbix file,pls see attached.

 

 

Best Regards,
Kelly

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

 

View solution in original post

2 REPLIES 2
v-kelly-msft
Community Support
Community Support

Hi  @Anonymous ,

 

First create a parameter table as below,which is for dynamic selection:

Slicer table = GENERATESERIES(1,12,1)

Then create  a  measure as below:

Measure = IF(
    NOT(ISFILTERED('Slicer table'[Value])),CALCULATE(SUM('Table'[Value])),
    IF(ISINSCOPE('Table'[Country]),CALCULATE(SUM('Table'[Value])),
 var _sum=CALCULATE(SUM('Table'[Value]),FILTER(ALL('Table'),'Table'[Year]>=MAX('Table'[Year])-SELECTEDVALUE('Slicer table'[Value])&&'Table'[Year]<=MAX('Table'[Year])))
 Return
 DIVIDE(_sum,SELECTEDVALUE('Slicer table'[Value]))))

And you will see:

v-kelly-msft_0-1617348342611.png

For the related .pbix file,pls see attached.

 

 

Best Regards,
Kelly

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

 

amitchandak
Super User
Super User

@Anonymous , Try a measure like

 

AverageX(summarize(Table, Table[City], Table[Year], "_1",[measure]) ,[measure])

 

Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.