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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
DebbieE
Community Champion
Community Champion

Get the Mean value in a list (Average isnt working)

AverageCas.JPG

 

I have a SUM(cas) as a Measure

 

And I also have a AVERAGE(Cas) Measure as above.

And I need to display the mean value from the Sum which should be around 347

I already have a filter applied on the years to get those years above on the date table

But I cant come up with DAX that does this

 

I eventually want to display it in a card so It will need to have the filter applied to it for the number of years but then show that mean value of Cas 

1 ACCEPTED SOLUTION

@DebbieE,

 

You could change the filter context to use the slicer years. In your subsequent DAX, add a variable:

 

VAR BaselineAvg =
CALCULATE (
    [Baseline Average],
    FILTER (
        ALL ( 'Date' ),
        'Date'[Year] >= EarliestYr
            && 'Date'[Year] <= LatestYr
    )
)

 

Use this variable BaselineAvg in your calculation:

 

VAR breakdownPart =
DIVIDE([Target] - BaselineAvg, LatestYr - EarliestYr)

 





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

Proud to be a Super User!




View solution in original post

8 REPLIES 8
DataInsights
Super User
Super User

@DebbieE,

 

Try these measures. [Mean Value] averages the yearly sums.

 

Sum Cas = SUM ( AverageTest[Cas] )

Mean Value = 
VAR vBaseTable =
    ADDCOLUMNS ( VALUES ( Dates[Year] ), "tmpSumCas", [Sum Cas] )
VAR vResult =
    AVERAGEX ( vBaseTable, [tmpSumCas] )
RETURN
    vResult

DataInsights_0-1606585118593.png

 





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

Proud to be a Super User!




Im getting 69.84 not 347. Is there anyway to add into the vbase table a filter on Area = "UK" and a BaseFlag = true in the date table? This is because there are only 5 years used for this Baseline average.

I ttied adding these in a CALCULATE to

vResult but it hasnt made a difference

@DebbieE,

 

Try this, with a slicer for Area.

 

Mean Value = 
VAR vBaseTable =
    ADDCOLUMNS (
        CALCULATETABLE (
            VALUES ( Dates[Year] ),
            Dates[Base Flag] = "True"
        ),
        "tmpSumCas", [Sum Cas]
    )
VAR vResult =
    AVERAGEX ( vBaseTable, [tmpSumCas] )
RETURN
    vResult

 





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

Proud to be a Super User!




So nearly there. This works perfectly as my card. However I use this in some more DAX that wants to use it as a single value but the filter for Dates are being applied for this one too. Is there any way I can disconnect this value so other subsequent DAX can use it just as a number?

This is the next bit of DAX its being applied in

Targets for column chart =
VAR LatestYr =
CALCULATE(
MAX('Date'[Year]),
ALLSELECTED('Date'[Year])
)

VAR EarliestYr =
CALCULATE(
MIN('Date'[Year]),
ALLSELECTED('Date'[Year])
)
VAR breakdownPart =
DIVIDE([Target] - [Baseline Average], LatestYr - EarliestYr)

RETURN
[Baseline Average] + breakdownPart * (MAX('Date'[Year]) - EarliestYr)
And I create a clustered column chart with dates from 2018 to 2033

@DebbieE,

 

Glad to hear the measure works for the card visual.

 

Regarding the second request, it sounds as if you want the user to select the years in the Date slicer, instead of using Dates[Base Flag] = "True". If that is the case, you would need a separate measure since the measure I provided is designed to use Dates[Base Flag] = "True".





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

Proud to be a Super User!




Im not quite sure. the measure is correct with the Base flag = true. But the second measure needs to use this measure as it its just a number, completely independant on all the filters etc set for that measure. It works perfectly if you create a measure of say = 346. So I need the lower level one to work in the 2nd of DAX as if it was a hardcoded value

@DebbieE,

 

You could change the filter context to use the slicer years. In your subsequent DAX, add a variable:

 

VAR BaselineAvg =
CALCULATE (
    [Baseline Average],
    FILTER (
        ALL ( 'Date' ),
        'Date'[Year] >= EarliestYr
            && 'Date'[Year] <= LatestYr
    )
)

 

Use this variable BaselineAvg in your calculation:

 

VAR breakdownPart =
DIVIDE([Target] - BaselineAvg, LatestYr - EarliestYr)

 





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

Proud to be a Super User!




Mine only comes to 69.85 instead of 346 even though im doing in in the same way above?

I dont understand the DAX enough to understand why this is

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors