Forum Discussion

DataSundowner's avatar
DataSundowner
Icon for Helper II rankHelper II
2 years ago
Solved

Average with Filter but only on the Total Row

Hello everyone. Say I have 3 numbers 10, 15 and 100, but I only want to calculate average for the numbers under 50, so (10+15)/2=12.5 in this case. I know normarlly I would just use a DAX like CALCULATE(AVERAGE(NUM), NUM<50). However, I want my table visual still show 100 under the column, but the total row returns 12.5. Something like below. Is it possible to achieve this? Thank you. 

 

 

  • try this..

     

    Average Under 50 = 
    VAR AverageUnder50 = CALCULATE(AVERAGE('Sample'[NUM]), 'Sample'[NUM] < 50)
    VAR SumOver100 = CALCULATE(SUM('Sample'[NUM]), 'Sample'[NUM] > 100)
    VAR CountUnder50 = CALCULATE(COUNTROWS('Sample'), 'Sample'[NUM] < 50)
    RETURN
    IF(
        ISINSCOPE('Sample'[Group]),
        IF(
            MIN('Sample'[NUM]) > 100,
            SumOver100,
            IF(
                CountUnder50 > 0,
                AverageUnder50,
                SUM('Sample'[NUM])
            )
        ),
        IF(
            CountUnder50 > 0,
            AverageUnder50,
            SUM('Sample'[NUM])
        )
    )

     

     

    If I answered your question, please mark this thread as accepted and Thums Up!
    Follow me on LinkedIn:
    https://www.linkedin.com/in/mustafa-ali-70133451/

  • Hi,

    Try these measures:

    Measure = average(Data[Num])

    Measure1 = if(hasonevalue(Data[Group]),[Measure],averagex(filter(values(Data[Group]),[Measure]<50),[Measure]))

    Hope this helps.

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi DataSundowner 

    You can try the following measure.

    Measure = SUM('Table'[Num])
    Measure 2 = IF(CALCULATE(AVERAGEX('Table',[Measure]),'Table'[Num]<50)=BLANK(),[Measure],CALCULATE(AVERAGEX('Table',[Measure]),'Table'[Num]<50))

    Output

    Best Regards!

    Yolo Zhu

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

     

     

3 Replies

  • amustafa's avatar
    amustafa
    Icon for Solution Sage rankSolution Sage

    try this..

     

    Average Under 50 = 
    VAR AverageUnder50 = CALCULATE(AVERAGE('Sample'[NUM]), 'Sample'[NUM] < 50)
    VAR SumOver100 = CALCULATE(SUM('Sample'[NUM]), 'Sample'[NUM] > 100)
    VAR CountUnder50 = CALCULATE(COUNTROWS('Sample'), 'Sample'[NUM] < 50)
    RETURN
    IF(
        ISINSCOPE('Sample'[Group]),
        IF(
            MIN('Sample'[NUM]) > 100,
            SumOver100,
            IF(
                CountUnder50 > 0,
                AverageUnder50,
                SUM('Sample'[NUM])
            )
        ),
        IF(
            CountUnder50 > 0,
            AverageUnder50,
            SUM('Sample'[NUM])
        )
    )

     

     

    If I answered your question, please mark this thread as accepted and Thums Up!
    Follow me on LinkedIn:
    https://www.linkedin.com/in/mustafa-ali-70133451/

  • Hi,

    Try these measures:

    Measure = average(Data[Num])

    Measure1 = if(hasonevalue(Data[Group]),[Measure],averagex(filter(values(Data[Group]),[Measure]<50),[Measure]))

    Hope this helps.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi DataSundowner 

    You can try the following measure.

    Measure = SUM('Table'[Num])
    Measure 2 = IF(CALCULATE(AVERAGEX('Table',[Measure]),'Table'[Num]<50)=BLANK(),[Measure],CALCULATE(AVERAGEX('Table',[Measure]),'Table'[Num]<50))

    Output

    Best Regards!

    Yolo Zhu

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