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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
achen
Frequent Visitor

Filtered Count from Another Table

Hi,

 

New user to PowerBi here and I am having a very hard time getting what I think should be a simple calculation.

 

I have 2 tables. 1 is "Orders" and another is "Incidents" that are linked by the "Order #".  I am trying to combine the two tables into a chart where it shows the number of "Pending" incidents per month (by "Incident Month") in a bar graph and the line graph will show the incident rate % (the number of "Pending" incidents dvided by the number of "Pending and "Service Request" Orders). Example of the desired graph shown below.

 

The bar graph is simple but I am having a lot of trouble getting the incident rate. I am having issues getting a count of the number of orders. All the things I have tired do not filter by month. I seem to just get a single number that doesnt break down into the months.

 

Can anyone explain what I am doing wrong?

 

ORDERS TABLE

Order #Order DateStatusType
O12-Oct-18PendingService Request
O215-Oct-18PendingReturn
O318-Oct-18CancelledService Request
O421-Oct-18PendingService Request
O527-Oct-18PendingService Request
O631-Oct-18PendingService Request
O71-Nov-18PendingService Request
O84-Nov-18PendingService Request
O95-Nov-18PendingService Request

 

INCIDENTS TABLE

Incident #Order #Incident DateStatus
I1O15-Oct-18Pending
I2O15-Oct-18Pending
I3O25-Oct-18Pending
I4O320-Oct-18Cancelled
I5O41-Nov-18Pending
I6O622-Nov-18

Pending

 

2018_12_12_14_09_29_Book6_Excel.png

1 ACCEPTED SOLUTION
Anonymous
Not applicable

The relationship will work.  Just many to many can lead to ambiguous models.  Anyhow, here's how I approached  this one:

 

1. You are going to need a data table that will work as filter for Incidents and Orders:

Date Table.png

make sure to use fields from that table as your slicers, filters, ect.

 

Then write a measure for Pending Incidents:

Pending Incidents = CALCULATE(COUNTROWS(Incidents),Incidents[Status]="Pending")

Then one for Pending and Service request from the Orders table:

Pending and Service Request = CALCULATE(COUNTROWS(Orders),Filter(Orders,Orders[Status]="Pending" && Orders[Type] = "Service Request"))

Then one last one to divide them out:

Pending Incidents divided by Pending and Service = 
DIVIDE([Pending Incidents], [Pending and Service Request])

Here's the final table. I cannot for life of me find the combo chart though:

Final Table.png

View solution in original post

7 REPLIES 7
achen
Frequent Visitor

Hi,

 

Sorry if this is a repost but my original thread seems to have been removed.

 

New user to PowerBi here and I am having a very hard time getting what I think should be a simple calculation.

 

I have 2 tables. 1 is "Orders" and another is "Incidents" that are linked by the "Order #".  I am trying to combine the two tables into a chart where it shows the number of "Pending" incidents per month (by "Incident Month") in a bar graph and the line graph will show the incident rate % (the number of "Pending" incidents dvided by the number of "Pending and "Service Request" Orders). Example of the desired graph shown below.

 

The bar graph is simple but I am having a lot of trouble getting the incident rate. I am having issues getting a count of the number of orders. All the things I have tired do not filter by month. I seem to just get a single number that doesnt break down into the months.

 

Can anyone explain what I am doing wrong? What formula do I need in order to get the count of the order per month?

 

ORDERS TABLE

Order #Order DateStatusType
O12-Oct-18PendingService Request
O215-Oct-18PendingReturn
O318-Oct-18CancelledService Request
O421-Oct-18PendingService Request
O527-Oct-18PendingService Request
O631-Oct-18PendingService Request
O71-Nov-18PendingService Request
O84-Nov-18PendingService Request
O95-Nov-18PendingService Request

 

INCIDENTS TABLE

Incident #Order #Incident DateStatus
I1O15-Oct-18Pending
I2O15-Oct-18Pending
I3O25-Oct-18Pending
I4O320-Oct-18Cancelled
I5O41-Nov-18Pending
I6O622-Nov-18

Pending

 

Desired Chart

2018_12_12_14_09_29_Book6_Excel.png

Anonymous
Not applicable

getting a number that seems to be a total and is repeating generally means there is a problem wiht the  relationships between the two tables.  Have a screenshot of the diagram view? 

 

I don't have access to the actual relationship dirgram, but I know that the only relationship between the two tables is the Order#

Anonymous
Not applicable

The relationship will work.  Just many to many can lead to ambiguous models.  Anyhow, here's how I approached  this one:

 

1. You are going to need a data table that will work as filter for Incidents and Orders:

Date Table.png

make sure to use fields from that table as your slicers, filters, ect.

 

Then write a measure for Pending Incidents:

Pending Incidents = CALCULATE(COUNTROWS(Incidents),Incidents[Status]="Pending")

Then one for Pending and Service request from the Orders table:

Pending and Service Request = CALCULATE(COUNTROWS(Orders),Filter(Orders,Orders[Status]="Pending" && Orders[Type] = "Service Request"))

Then one last one to divide them out:

Pending Incidents divided by Pending and Service = 
DIVIDE([Pending Incidents], [Pending and Service Request])

Here's the final table. I cannot for life of me find the combo chart though:

Final Table.png

Anonymous
Not applicable

That's a many to many relationship, which can have some interesting results.  Do you  have the option to create another table using Power Query?

Yes I could create another table if needed. But I am not sure what kind kind of table I would need to create in order to get what I am looking for.

achen
Frequent Visitor

Sorry and I just noticed an error in my table above. The order # will always be unique. I had a typo there where O8 showed twice. The incident number will always be unique as welll. However htere can be mutliple incidents linked to one order.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors