Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Calculate the average based on week period

Hello, 

 

I am kind of new to power Bi, data visualizacion and report construction. I am trying to build a demand graph based on a weekly demand. 

 

 
 

The Graph shows the demand volume based on the different weeks. The week value is set through another table of periods which is associated with a date value from the demand table. As you may see, I have already an average line on the visualization with a very small, hard to see '4' number over there.

 

I want to show  the average per week on the data card that is set at the left. Any ideas on how I could be able to achieve this? I don't know how to calculate this average per week. 

  • Hi Anonymous ,

     

    What you need is to create 2 measures :

    1.Create a measure to get value of “Proposals demand”:

     

    Proposal demand =

    VAR week =
    MAX ( 'Date'[Week of year] )
    VAR p =
    MAX ( 'Date'[Period] )
    VAR k =
    ADDCOLUMNS (
    Demand,
    "ind", CALCULATE (
    MAX ( 'Date'[Period] ),
    FILTER (
    'Date',
    'Date'[Week of year] = Demand[Week of year]
    && 'Date'[Index] = Demand[Index]
    )
    )
    )
    RETURN
    CALCULATE (
    SUM ( Demand[Proposals Demand per week] ),
    FILTER ( k, Demand[Week of year] = MAX ( 'Date'[Week of year] ) && [ind] = p )
    )


    2. show the “average ” in a card:

    Average of proposals demand per week= AVERAGE('Demand'[Proposals Demand per week])
     

    3.Then you will see as below:

    For the related .pbix file,pls turn to URL: https://microsoftapc-my.sharepoint.com/:u:/g/personal/v-kellya_microsoft_com/EZrxK33QIJJFh1P_nskya94B47Z-f_BqWT7qb4I-emY2zQ?e=nr41Dw

    Hope this would help.

     

    Best Regards,

    Kelly

     

     

1 Reply

  • v-kelly-msft's avatar
    v-kelly-msft
    Icon for Community Support rankCommunity Support

    Hi Anonymous ,

     

    What you need is to create 2 measures :

    1.Create a measure to get value of “Proposals demand”:

     

    Proposal demand =

    VAR week =
    MAX ( 'Date'[Week of year] )
    VAR p =
    MAX ( 'Date'[Period] )
    VAR k =
    ADDCOLUMNS (
    Demand,
    "ind", CALCULATE (
    MAX ( 'Date'[Period] ),
    FILTER (
    'Date',
    'Date'[Week of year] = Demand[Week of year]
    && 'Date'[Index] = Demand[Index]
    )
    )
    )
    RETURN
    CALCULATE (
    SUM ( Demand[Proposals Demand per week] ),
    FILTER ( k, Demand[Week of year] = MAX ( 'Date'[Week of year] ) && [ind] = p )
    )


    2. show the “average ” in a card:

    Average of proposals demand per week= AVERAGE('Demand'[Proposals Demand per week])
     

    3.Then you will see as below:

    For the related .pbix file,pls turn to URL: https://microsoftapc-my.sharepoint.com/:u:/g/personal/v-kellya_microsoft_com/EZrxK33QIJJFh1P_nskya94B47Z-f_BqWT7qb4I-emY2zQ?e=nr41Dw

    Hope this would help.

     

    Best Regards,

    Kelly