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

Help with static average

Hello,

 

I need to sum the column Amount for the past 10 years using the offset 0 to -9 then divide by 10 (because I'm using last 10 years)

 

Then I need a new DAX measure that will always display the result of 394.3 (total sum /10) in the Line graph no matter if I change the filter slicer date.

 

Year offset and Year columns come from Dim_date 

Amount comes from Fact_table

Relationship by date

 

YEAR OFFSETYEARAmountResult wanted
-112010254394.3
-102011500394.3
-92012350394.3
-82013152394.3
-72014365394.3
-62015214394.3
-52016125394.3
-42017548394.3
-32018952394.3
-22019214394.3
-12020365394.3
02021658394.3
  3943 (total past 10 months) 
  394.3 (total / 10) 

 

Any ideas? Thanks!!

1 ACCEPTED SOLUTION

Hi, @Anonymous 

I do not know the reason why you created the page level filter.

But in order to meet your request, I needed to delete your page-level filter and put those into the measure itself. 

When you are applying this to your own model, please try to delete the page level filter and put those into the measure like below.

 

Please check the link below.

 

Picture4.png

 

_Take Up - 10 Years Average2 =
VAR lastyearoffset =
CALCULATE ( MAX ( dim_Date[Year Offset] ), ALL ( dim_Date ) )
VAR lastyearstotal =
CALCULATE (
SUM ( fct_10YR_JLLREDS_Demand[Area Leased sqm] ),
FILTER (
ALL ( dim_Date ),
dim_Date[Year Offset] >= lastyearoffset - 9
&& dim_Date[Not future date] = 1
)
)
RETURN
IF (
NOT ISBLANK ( SUM ( fct_10YR_JLLREDS_Demand[Area Leased sqm] ) ),
DIVIDE ( lastyearstotal, 10 )
)

 

https://www.dropbox.com/s/z9pzvg3wowcthuv/fabtest.pbix?dl=0 

 

 

Hi, My name is Jihwan Kim.

 

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

 

Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


View solution in original post

11 REPLIES 11
Jihwan_Kim
Super User
Super User

Hi, @Anonymous 

Please check the below picture and the sample pbix file's link down below.

 

Picture4.png

 

Amount avg past 10 years =
VAR lastyearoffset =
CALCULATE ( MAX ( Dates[YEAR OFFSET] ), ALL ( Dates ) )
VAR lasttenyearstotal =
CALCULATE (
SUM ( 'Fact'[Amount] ),
FILTER ( ALL ( Dates ), Dates[YEAR OFFSET] >= lastyearoffset - 9 )
)
RETURN
DIVIDE ( lasttenyearstotal, 10 )
 
 
 

Hi, My name is Jihwan Kim.


If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.


Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Anonymous
Not applicable

Hi Jihwan,

 

Please see below the real data set with your formula.

 

For some reason the the numbers aren't matching up. So I'm returning only the result of the sum to check and the sum is way higher than it should be. The relationship between date and fact is made on quarter level repeating the day on the date table side (e.g q1 01/01/2021... in each line)

 

fabnishi1207_0-1620708932802.png

 

Hi, @Anonymous 

Thank you for your feedback.

I am not sure how you wrote the measure, [Area leased sqm].

Please try to put this measure into my measure, and replace it with sum() part.

Or, please share your sample pbix file's link here, then I can try to come up with a more accurate measure.

Thanks.

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Anonymous
Not applicable

Hi, @Jihwan_Kim 

This is your measure,

the [Area leased sqm] is just a raw data from the fct table.

The result should be around 2,3m and not 5m

The reason is because the sum of the area leased sqm is wrong

fabnishi1207_0-1620712382180.png

 

It is quite difficult for me to step further.

 

please share your sample file's link.

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Anonymous
Not applicable

here is the file the page, is the test page.

Dropbox

https://www.dropbox.com/s/onjewhcu077bsvt/fabtest.pbix?dl=0

 

Thank you

Hi, @Anonymous 

Thank you for sharing.

I am not sure how the filters are applied to the whole page, but there are some filters applied to the page level.

Please check the below picture and the measure below.

I hope the number is the one that is expected.

 

Picture1.png

 

_Take Up - 10 Years Average2 =
VAR lastyearoffset =
CALCULATE( MAX (dim_Date[Year Offset] ) , ALL (dim_Date ) )
VAR lastyearstotal =
CALCULATE(
SUM(fct_10YR_JLLREDS_Demand[Area Leased sqm] ),
FILTER( ALLSELECTED(dim_Date ), dim_Date[Year Offset] >= lastyearoffset - 9)
)
RETURN
DIVIDE(lastyearstotal,10)
 
 
 
 

Hi, My name is Jihwan Kim.


If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.


Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Anonymous
Not applicable

Hi, 

 

Thanks for the feedback.

 

I'm still with the same issue as I had before.

I need the value of 2,3m statics even though when Year slicer is selected for a specific range of years.

 

fabnishi1207_0-1620736763106.png

 

Hi, @Anonymous 

I do not know the reason why you created the page level filter.

But in order to meet your request, I needed to delete your page-level filter and put those into the measure itself. 

When you are applying this to your own model, please try to delete the page level filter and put those into the measure like below.

 

Please check the link below.

 

Picture4.png

 

_Take Up - 10 Years Average2 =
VAR lastyearoffset =
CALCULATE ( MAX ( dim_Date[Year Offset] ), ALL ( dim_Date ) )
VAR lastyearstotal =
CALCULATE (
SUM ( fct_10YR_JLLREDS_Demand[Area Leased sqm] ),
FILTER (
ALL ( dim_Date ),
dim_Date[Year Offset] >= lastyearoffset - 9
&& dim_Date[Not future date] = 1
)
)
RETURN
IF (
NOT ISBLANK ( SUM ( fct_10YR_JLLREDS_Demand[Area Leased sqm] ) ),
DIVIDE ( lastyearstotal, 10 )
)

 

https://www.dropbox.com/s/z9pzvg3wowcthuv/fabtest.pbix?dl=0 

 

 

Hi, My name is Jihwan Kim.

 

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

 

Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Anonymous
Not applicable

@Hi, @Jihwan_Kim 

 

Thanks for your solution. It's working now

 

The reason I put that filter on the page level is to make my life easier as in the original dashboard I have many pages and measures that contain values with no dates and I don't want to display them in the visuals.

 

thank you!

amitchandak
Super User
Super User

@Anonymous , check if one of the two options (for a new measure can help)

 

averageX(summarize(allselected(Table), Table[year offset], Table[Year] , "_1", [Amount]),[_1])


calculate(averageX(values(Table[year offset]) , [Amount]),allselected(Table))

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.