Forum Discussion

andreaaizza's avatar
andreaaizza
New Member
9 years ago
Solved

Average count per month per id

Hi there, 

 

have some measurement like below: 

iddatemeasure
id11.6.20171010
id210.7.20171016
id21.6.201710
id210.7.201720
id215.7.201726


Trying to calculate an average of counts per month per id, as done below with excel. Can anybody help me to do it with powerbi?

 

Count per month, per id:

idmonthcount_per_month
id1Jun.171
id1Jul.171
id2Jun.171
id2Jul.172

 

Desired result: average count per month: 

monthave_count_per_month
Jun.171
Jul.171,5

 

Cheers, 

Andrea

  • andreaaizza

     

    Hi, you can obtain the desired result in this way:

     

    Step 1: In Query Editor

     

    Parse the Date and Create the column Month-Year

     

     

    Step 2:

     

    Create a Measure:

     

    AVG_Count_Per_month =
    AVERAGEX (
        SUMMARIZE (
            Table1,
            Table1[month-year],
            Table1[id],
            "Count", COUNT ( Table1[id] )
        ),
        [Count]
    )

    Ready

     

8 Replies

  • Vvelarde's avatar
    Vvelarde
    Community Champion

    andreaaizza

     

    Hi, you can obtain the desired result in this way:

     

    Step 1: In Query Editor

     

    Parse the Date and Create the column Month-Year

     

     

    Step 2:

     

    Create a Measure:

     

    AVG_Count_Per_month =
    AVERAGEX (
        SUMMARIZE (
            Table1,
            Table1[month-year],
            Table1[id],
            "Count", COUNT ( Table1[id] )
        ),
        [Count]
    )

    Ready

     

  • dilumd's avatar
    dilumd
    Impactful Individual

    Hi,

     

    Please use below function,

    m_MonthlyAvg = DIVIDE(SUMX('Count',[m_Count]),COUNTA('Count'[Count]))

     

      • dilumd's avatar
        dilumd
        Impactful Individual

        Hi

         

        you can just create a new measure using SUM function

         

        =SUM(‘Tablename’[ColumnName])

         

        reason for this is that you can only use measures inside of a expression. 😊