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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
austinjgreer
Frequent Visitor

Division with a Filter

Hello,

 

I'm trying to divide using the count of values in one column, by the count of values in another column within a different table. 
What I had originally was: Scan Rate = DIVIDE (COUNT (Table1[IP Address]), COUNT ('Table2'[Hostname]))

and that worked great. But after combining files, I now want to do the same division but with a filter (if possible).

 

I have 2 columns:

 

IP Address          Month Reported

1.2.3.4                 March 2022

1.2.3.5                 February 2022

 

Originally, with the one column (IP Address), I was getting the correct percentage. But after combining files it comes to an inflated percentage because it's counting ALL cells within the column, regardless of what month is in the Month Reported column. 

So if I could get the following:

 

IP Address     Month Reported     Percentage

1.2.3.4            March 2022             98%

1.2.3.5            February 2022         93%

Hopefully this makes sense. Thank you in advance for the assistance!

9 REPLIES 9
johnt75
Super User
Super User

Create a date table linked to both Table1 and Table2. Use the year / month column from the date table on your visual and your existing measure should work fine.

Apologies if I'm misunderstanding, I'm still fairly new to PowerBI.

 

This is all still in the Data tab and it is a column that I'm creating, not a measure. Is the auto date/time setting not sufficient for this?

 

The result I'm getting is 532% in the Percentage column because it is counting ALL IPs in Table 1 and dividing it by the count of IPs in Table 2.

Is the column going on the table with the IP addresses or the hostnames. And do both tables have a month column?

The column is going into Table 1. Table 2 is a static list of ~6500 IPs/hostnames that does not change and has no dates on it.

try

Percentage = DIVIDE( CALCULATE( COUNTROWS('Table1'), 
ALLEXCEPT( 'Table1', 'Table1'[IP Address], 'Table1[Month]) ), COUNTROWS('Table2') )

Tried it, and now I'm getting .02% for all rows. 

can you provide a sample PBIX ?

lbendlin
Super User
Super User

Please provide sanitized sample data that fully covers your issue.

Please show the expected outcome based on the sample data you provided.

Hi! The sample data is above in the OP but I'll put it below too:

 

IP Address          Month Reported

1.2.3.4                 March 2022

1.2.3.5                 February 2022

1.2.3.6                 November 2021

 

The desired output is:

 

IP Address     Month Reported     Percentage

1.2.3.4            March 2022             98%

1.2.3.5            February 2022         93%

1.2.3.6            November 2021      96%

 

What I have now is: 

Percentage = DIVIDE (COUNT(Table 1[IP Address]), COUNT('Table 2'[IP Address]))

 

So I'm counting the number of IPs in Table 1 and dividing it by the count of IPs in Table 2. But it's counting all IPs in Table 1 regardless of the month listed in the Month Reported column. Hopefully this is clearer.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors