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
Anonymous
Not applicable

Calculate rate from two related tables

Hi there! I'm new to Power BI and have been trying for the last few days to create some measures functions but no luck!

In summary, I have two tables loaded in PBI Desktop file that look like:

 

Table 1

CustomerDateEvent type
A3-Apr-17AA
A10-Jun-17BB
A1-Jan-17GG
B30-Nov-16AA
C17-Oct-15GG
A3-Apr-17TT
A10-Jun-17HH
A1-Jan-17BB
C30-Nov-16CC
A17-Oct-15RR
C3-Apr-17SS
B10-Jun-17DD
C1-Jan-17CC

 

The second table looks like:

 

Table 2

CustomerMonthMonthly Utilization
A1-Jan-1715
A1-Feb-1710
A1-Mar-1713
B1-Jan-1717
B1-Feb-1720
B1-Mar-1780
C1-Jan-1740
C1-Feb-1710
C1-Mar-1712
D1-Jan-1714
D1-Feb-1734
D1-Mar-1754

 

I want to create a visual showing the monthly rate of different type of events (in this case AA, BB, GG, etc...) for the different customers defined simply as:

Event Rate of one event type for a particular customer = Number of events in a particular month of that particular operator / Monthly Utilization of that particular customer.

 

So far I've just created a table in PBI with the "DISTINCT" function that simply created a column with all the operator names. I've created 2 relationships between this column and the operator columns of Table 1 & 2.

 

Could you please help me in creating measures to calculate those rates? I've tried with the COUNTA function to count the different number of events for each customer, however that only calculates the total number of events for each customer. It doesn't calculate the totals for every month. Also, I'd like the functions to be rolling, i.e. it should keep calculating the last 4 months of rates from "today".

 

Thanks a lot!

3 REPLIES 3
v-sihou-msft
Microsoft Employee
Microsoft Employee

@Anonymous

 

I'm still not quite clear about your requirement. 

 

Event Rate of one event type for a particular customer = Number of events in a particular month of that particular operator / Monthly Utilization of that particular customer

 

Is "Number of events in a particular month of that particular operator" group on event type and month?

 

I suggest you add a "first day of month" column in Table 1.

 

Month = Table1[Date]-DAY(Table1[Date])+1

Then you can create a measure to calculate the count of events group on Month and Event Type.

 

Measure = CALCULATE(COUNTROWS(),ALLEXCEPT(Table1,Table1[Customer],Table1[Event type],Table1[Month]))

Regards,

Anonymous
Not applicable

Hello,

 I've created and uploaded a dummy file here. My end goal is to have a gauge where if I select a data range, operator and type of failure the value will be the average of the rates for all the months. included in the data range I selected. At the moment the value shown by the gauge is simply the sum of the rates, and not the average. As I understand it, there are currently 2 issues:

 

1- value is a total and not the average of the monthly rates

2- even if the value was an average, since the Rate measure doesn't return any value for months where there were no failure events, the average would be wrong. I need Rate measure to return "0" every month when there are no failure events.

 

Thank you!

Anonymous
Not applicable

Thank you very much Simon.

I was able to create a measure like you said called "Events". What I need to do now is calculate the ratio between "Events" and the number of hours that the asset was used in a particular month. The number of hours is in Table 2 that looks like:

 

Date            Operator      Asset             Utilization (hours)

04-2017            A               X                              10

04-2017            B               Y                              20

04-2017            B               Z                              30

 

I have created three relationships between Date, Operator and Asset of Table 1 & Table 2. How can I create this other measure to calculate the ratio between "Events" and utilization?

 

For example:

Operator B in April 2017 had 2 events using the asset Y (this is calculated by the measure "Events").  I would like now to calculate the rate of events for the asset Y in April 2017:  Rate = 2 events / 20 hours

 

Thanks a lot.

 

Regards

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