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
computermike
Helper I
Helper I

Need help writting a measure to average for three years

I have a Report for 2016 that shows sums of rev by product.  I have graphs and filters for Area, Product line, month and my main graph shows rev by location.  The grain of the data is Rev aggregated by Product line, Month & location ( hierarchy = location, zip, sales area).  So I have one record for Feb at location "W" for Product "STW" and the rev.  All my data is for 2016 and that is the title of my report.

 

My model include a Product Line, Location and Date dimension and a Rev fact table.

 

Now I want to reproduce the exact same report, but instead of showing data for 2016.  I want to show data for 2014, 2015 and 2016.  I want to show the averages for these three years.  So my title will be 2014-2016 Averages..  instead of 2016.

 

I recreated the same data model with data from all three years.  Now I just need to created a measure that average the three years.  Then I can sum it and place it in my report.  Only problem is I am not sure how to write this measure.  Once I write it I will just sum it so the Sales Area totals, Product line Totals will sum correctly.

 

Can anyone help me get started with this measure, and/ or comment if they see anything wrong with this approach?

 

Thanks,

 

Mike

1 ACCEPTED SOLUTION
computermike
Helper I
Helper I

I figured it out.

 

sum(fRev[RevAmt])/DISTINCTCOUNT(dDate[Year])

View solution in original post

3 REPLIES 3
computermike
Helper I
Helper I

I figured it out.

 

sum(fRev[RevAmt])/DISTINCTCOUNT(dDate[Year])

When I first wrote that I used DISINCTCOUNT(Related(dDate[Year]) but got an error.  I am surprised that gave me an error.  I am on chapter 3 of the definative guide to Dax and it mentioned that if you ever used a column from a different table you needed the "Related" keyword.

 

I could never get the Average function to work.  It was always just averaging every row.

 

I guess DAX is a learnng curve.  Smiley Happy

Phil_Seamark
Employee
Employee

You could start with

 

Average Rev = CALCULATE(Average('FactTable'[Rev]))

 

And see what that gives you.


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

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.

Top Solution Authors