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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
mrizvi
Helper I
Helper I

Getting the Average from a Y/N column

Hello Power Bi community

 

This is a sample of my data table 

Site NameDateStatusMeets Criteria
Nashville11/10/2020VerifiedY
N. Dallas09/22/2020 N
Danville2/5/2020 N
Danville6/6/2020Verified CVS PharmY

 

I am trying to use the Meets Criteria column to get a monthly average of each site's orders. If the site has a "Y" in the last column that means they met the criteria and vise versa for "N". I need to determine how to create a measure (or a column) to build a matrix visual scorecard showing each site's monthly average of the number of orders that were verified and met the criteria (i.e. "Y")

 

Thanks,

 

M.R

1 ACCEPTED SOLUTION

@mrizvi  OK, so you are looking for percentage by Site Name. Try these measures: 

 

Total Orders Verified = CALCULATE( COUNT( Table[OrderId]) , Table[Status] = "Verified", Table[ Meets Criteria] = "Y" )

Total Orders = COUNT( Table[OrderID]) 

 

Percent Verified = DIVIDE( [Total Orders Verified] , [Total Orders] )

 

Use a slicer for Site Name or put Percent Verified in a visual with Site Name. If you want this to work when drilling down to order ID level, you'll need to add another filter context shift, for example using: 

 

Percent Verified This Site = CALCULATE( DIVIDE( [Total Orders Verified] , [Total Orders] ), ALLEXCEPT(Table[Site Name])


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

View solution in original post

5 REPLIES 5
V-pazhen-msft
Community Support
Community Support

@mrizvi 

Could you clarify your requirement, you want the monthly average count, just count the monthly order that meet the 2 conditions? And in the Status column, are there any other status other than Verified, and Verified CVS Pharm?

 

Regards
Paul

There are a lot more status. Most all will have verified. If the order was not verified... The row is blank. 

 

AllisonKennedy
Super User
Super User

@mrizvi  Do you also have an OrderNumber or ID in this table? I would guess measure would look something like:

 

Total Orders Verified and Meet = CALCULATE( COUNT( Table[OrderId]) , Table[Status] = "Verified", Table[ Meets Criteria] = "Y" )

 

I'm not sure what you want to calculate the average over - see if this post helps explain why that's important: https://excelwithallison.blogspot.com/2020/09/what-does-average-mean.html

 

So if you can provide more context on how AVERAGE is calculated, that would help us help you.


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

@AllisonKennedy I do have the Order ID as one of the columns in the same table.

 

I need to know which sites had 85% verified orders per month. 

@mrizvi  OK, so you are looking for percentage by Site Name. Try these measures: 

 

Total Orders Verified = CALCULATE( COUNT( Table[OrderId]) , Table[Status] = "Verified", Table[ Meets Criteria] = "Y" )

Total Orders = COUNT( Table[OrderID]) 

 

Percent Verified = DIVIDE( [Total Orders Verified] , [Total Orders] )

 

Use a slicer for Site Name or put Percent Verified in a visual with Site Name. If you want this to work when drilling down to order ID level, you'll need to add another filter context shift, for example using: 

 

Percent Verified This Site = CALCULATE( DIVIDE( [Total Orders Verified] , [Total Orders] ), ALLEXCEPT(Table[Site Name])


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.