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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Johannes_W
Regular Visitor

Yearly average of an aggregate measure, again

 Dear all,

 

it seems this kind of question comes up often, but I can not seem to find a solution.

Here is my situation.

 

I have a list of prcesses that happen at a specific date. Each process has a number of events (some just a few, some hundreds) which may or may not fail.

 

Table1

Process   event_id   failed?   
A10
A20
A31
B41
B51
C60
C70
D80
D91
D101
D110

 

I also have a date table that tells me in which year the processes have run

A2020
B2020
C2019
D2019

 

I have created a measure that claculates for each process the percentage of failed events

 

%failed = DIVIDE( SUM('Table1'[failed]), COUNT('Table1'[event_id]) )
 
very naively, I just sum up the 1s and divide by the number of events.
 
This works nicely when I look at the individual processes.
Process  %failed  Year  
A33%2020
B100%2020

C

0%

2019

D

50%

2019

 

However: what I would like to achieve is a measure that now gives me the average %failed over all processes each year
(2020 = 66.5%, 2019 = 25%)
 
When I simply slice by year, what I get is the total % of all EVENTS in that year, not the average percentage by process.
(2020 = 60% and 2019 = 40 %)
This doesn't help me, because as I said, the number of events can differ vastly thus ruining the statistics.
 
Any advice is apprechiated.
Thanks!
Joh
1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi, @Johannes_W 

Please check the below picture and the sample pbix file's link down below.

When you put the Process column into the visualization, the correct result is still shown.

 

Picture4.png

 

failed percentage =
VAR newtable =
SUMMARIZE (
Data,
Data[Process],
"@idcount", COUNT ( Data[event_id] ),
"@failed", SUM ( Data[failed] )
)
RETURN
AVERAGEX ( newtable, [@failed] / [@idcount] )
 
 
 
 

Hi, My name is Jihwan Kim.


If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.


Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi, @Johannes_W 

Please check the below picture and the sample pbix file's link down below.

When you put the Process column into the visualization, the correct result is still shown.

 

Picture4.png

 

failed percentage =
VAR newtable =
SUMMARIZE (
Data,
Data[Process],
"@idcount", COUNT ( Data[event_id] ),
"@failed", SUM ( Data[failed] )
)
RETURN
AVERAGEX ( newtable, [@failed] / [@idcount] )
 
 
 
 

Hi, My name is Jihwan Kim.


If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.


Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Dear Jihwan,

 

that works perfectly, thank you so much! I need to ponder on why it works though.

Thanks!

Joh

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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