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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
epmck11
Frequent Visitor

Problem dividing one column by another

I'm very new to Power BI, so please go easy on me here. I am trying to calculate scanning percentage based on branch. So my data would look something like this:

 

Branch Electronic Signature

ABC     Y

DEF     Y

ABC     N

 

The idea is if product has an electronic signature, it would be a "Y", if not, it would be a "N". I created an additional column that says:

 

Scanned = IF (Query1[Electronic Signature] = "Y", 1, 0)  

 

This works and allows me to turn the scanned into a numeric so I can figure out the percentage. So I want to figure out what percentage of stops were scanned, so I create another measure:

 

Scan Percent = sum(Query1[Scanned]) / countrows(Query1)

 

But I am getting data that matches nothing like I am expecting. What am I doing wrong? What is a better way to do this? Please help and I'm sorry for the newb question! 

1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

Hi @epmck11,

 

According to your description, you want to calculate the percent of signed records of current type, right?

Percent of current Branch =
CALCULATE (
COUNTA ( 'Table'[Electronic Signature] ),
'Table'[Electronic Signature] = "Y",
VALUES ( 'Table'[Name] ),
ALLSELECTED ( 'Table' )
)
/ CALCULATE ( COUNTROWS ( ALLSELECTED ( 'Table' ) ), VALUES ( 'Table'[Name] ) )

Percent of all Branch=
CALCULATE (
COUNTA ( 'Table'[Electronic Signature] ),
'Table'[Electronic Signature] = "Y",
VALUES ( 'Table'[Name] ),
ALLSELECTED ( 'Table' )
)
/ COUNTROWS ( ALLSELECTED ( 'Table' ) )

9.PNG

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

5 REPLIES 5
v-shex-msft
Community Support
Community Support

Hi @epmck11,

 

According to your description, you want to calculate the percent of signed records of current type, right?

Percent of current Branch =
CALCULATE (
COUNTA ( 'Table'[Electronic Signature] ),
'Table'[Electronic Signature] = "Y",
VALUES ( 'Table'[Name] ),
ALLSELECTED ( 'Table' )
)
/ CALCULATE ( COUNTROWS ( ALLSELECTED ( 'Table' ) ), VALUES ( 'Table'[Name] ) )

Percent of all Branch=
CALCULATE (
COUNTA ( 'Table'[Electronic Signature] ),
'Table'[Electronic Signature] = "Y",
VALUES ( 'Table'[Name] ),
ALLSELECTED ( 'Table' )
)
/ COUNTROWS ( ALLSELECTED ( 'Table' ) )

9.PNG

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
epmck11
Frequent Visitor

I'm very new to Power BI, so please go easy on me here. I am trying to calculate scanning percentage based on branch. So my data would look something like this:

 

Branch Electronic Signature

ABC     Y

DEF     Y

ABC     N

 

The idea is if product has an electronic signature, it would be a "Y", if not, it would be a "N". I created an additional column that says:

 

Scanned = IF (Query1[Electronic Signature] = "Y", 1, 0)  

 

This works and allows me to turn the scanned into a numeric so I can figure out the percentage. So I want to figure out what percentage of stops were scanned, so I create another measure:

 

Scan Percent = sum(Query1[Scanned]) / countrows(Query1)

 

But I am getting data that matches nothing like I am expecting. What am I doing wrong? What is a better way to do this? Please help and I'm sorry for the newb question! 

@epmck11,

I  use your measure to create the following table, does it return your expected result? If not, please post your desired result.

1.JPG

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Yes, that would be my expected result.

@epmck11,

What is your current issue?

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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