Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
mrizvi
Helper I
Helper I

Average of column filtered by month

Hello all,

 

I am working with a data set that has three columns (designed below) - 1) Order date - 2) "Was the order included" - 3) Site Name. 

Order Date

Was the order included?

Site Name

09/02/2020

     Y

Danville

10/05/2020

     N

Clinch

10/22/2020

     N

Dallas North

11/22/2020

     Y

Dallas North

11/09/2020

     Y

Dallas North

 

What I'm trying to do is use the "Was the order included" column to get an average score of the number of orders that were included (ie "Y" for that row) filtered out for each month. 
For example: If for the month of October -- Clinch had a total of 50 orders and 45 of them were included (ie 45 with "Y" and 5 with "N") then the average for that month would show as 90% 

How can I set this formula up for my report?

Thanks

M.R

1 ACCEPTED SOLUTION
v-xulin-mstf
Community Support
Community Support

Hi, @mrizvi 

Depending on your needs, the following Measure is recommended

 

Measure =

var _month = MONTH(SELECTEDVALUE('Table'[Order Date]))

var a =

CALCULATE(

    COUNTROWS('Table'),

    FILTER(

        ALL('Table'),

        'Table'[Was the order included?] = "Y" &&

        MONTH('Table'[Order Date]) = _month

    )

)

var b =

CALCULATE(

    COUNTROWS('Table'),

    FILTER(

        ALL('Table'),

        MONTH('Table'[Order Date]) = _month

    )

)

return

a / b

 

The result is as follows:

v-xulin-mstf_0-1608258828114.png

 

Here is the sample file that you can refer:

https://qiuyunus-my.sharepoint.com/:u:/g/personal/admin_qiuyunus_onmicrosoft_com/EVuLjL9r7khIiwUFyjb...

 

Best Regards,

Link Chen

 

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

View solution in original post

2 REPLIES 2
v-xulin-mstf
Community Support
Community Support

Hi, @mrizvi 

Depending on your needs, the following Measure is recommended

 

Measure =

var _month = MONTH(SELECTEDVALUE('Table'[Order Date]))

var a =

CALCULATE(

    COUNTROWS('Table'),

    FILTER(

        ALL('Table'),

        'Table'[Was the order included?] = "Y" &&

        MONTH('Table'[Order Date]) = _month

    )

)

var b =

CALCULATE(

    COUNTROWS('Table'),

    FILTER(

        ALL('Table'),

        MONTH('Table'[Order Date]) = _month

    )

)

return

a / b

 

The result is as follows:

v-xulin-mstf_0-1608258828114.png

 

Here is the sample file that you can refer:

https://qiuyunus-my.sharepoint.com/:u:/g/personal/admin_qiuyunus_onmicrosoft_com/EVuLjL9r7khIiwUFyjb...

 

Best Regards,

Link Chen

 

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

amitchandak
Super User
Super User

@mrizvi , Create a measure like this and try

 

divide(calculate(countrows(Table), filter(Table,Table[Was the order included] ="Y")),countrows(Table))

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.