Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Grouping

Hello, So I need help with calculation. Table has many columns. One of them is order number (one number is repeted but has different data). Just example: Order NR Client Price 214 a 30 ...
  • johnt75's avatar
    3 years ago

    Try

    Avg Price per order number =
    AVERAGEX (
        ADDCOLUMNS (
            VALUES ( 'Table'[Order number] ),
            "@val", CALCULATE ( SUM ( 'Table'[Price] ) )
        ),
        [@val]
    )
    
  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi  Anonymous ,

     

    Here are the steps you can follow:

    Measure:

    Measure =
    var _sum=SUMX(ALL('Table'),[Price])
    var _count=CALCULATE(DISTINCTCOUNT('Table'[Order NR]),ALL('Table'))
    return
    DIVIDE(_sum,_count)

    Calculated column:

    Column =
    var _sum=SUMX(ALL('Table'),[Price])
    var _count=DISTINCTCOUNT('Table'[Order NR])
    return
    DIVIDE(_sum,_count)

    Result:

     

    Best Regards,

    Liu Yang

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