Forum Discussion

sirros_iot's avatar
sirros_iot
Helper III
8 years ago

Average by ID

Hello All!

 

It seems like very easy but I'm having trouble with it. OBS: I'm getting the data by live concection( Importing dataset from power BI online)

The table I have
ID                 Value   
1                      5
2                      2
1                      3
2                      6          

What I want with the measure
ID                 Value             measure
1                      5                      4
2                      2                      5
1                      3                      4
2                      8                      5

I tried to use quick measures but It didn't return me te right thing

 

Best Regards,

Diego 

7 Replies

  • You need to add a measure to something like this

     

    Measure = var m = FIRSTNONBLANK(Table1[id], "") 
    return CALCULATE(AVERAGE(Table1[value]), FILTER(ALLSELECTED(Table1),m =Table1[id]))
  • Hi sirros_iot,

     

    Try this:

     

    avg by id =
    CALCULATE (
    AVERAGEX ( ALL ( 'Table'[ID] ), AVERAGE ( 'Table'[Value] ) ),
    ALLEXCEPT ( 'Table', 'Table'[ID] )
    )
  • Thank you for the answers,

    parry2k is returning by ID but the average isn't right...

    danextian is returning the right average but it isn't by ID...

    I'll look where I can put both answers together to solve this issue.

    Thanks,

    Best Regards,

    Diego

    • parry2k's avatar
      parry2k
      Super User

      sirros_iotif you put Id and this new measure in a table view, I expect the result to be correct. Could you share what result you are getting? Why it is not correct?

      • Sean's avatar
        Sean
        Community Champion

        sirros_iot

        This should do it (and should work as a column too)

         

        Measure =
        CALCULATE ( AVERAGE ( Table1[Value] ), ALLEXCEPT ( Table1, Table1[ID] ) )

         

        parry2k's solution works too.

        But why write so much? :smileyvery-happy: