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 percentage per category with exception rules

Hi all,

 

I have a report that checks if files were delivered on time (= Timeliness). These files are delivered in batches (multiple files are sent at once). I already have the timeliness calculated for each file and now I want to calculate this per batch. I was successful with this, also in applying the rule that if one file in the batch was late, that the timeliness for this batch is 0% and only if all files of a batch are on time then they are 100%. My problem now is, that it will not calculate an average timeliness on the column "Timeliness (Batch) %" which for now shows in all other cases the right value. I have created another column called "T Batch" to test some formulas. Here it shows an average in the total row, but the batch timeliness is calculated wrong. Mathematically the 50% here is right but if its < 100% it needs to be set to 0%.

 

MIMQ_0-1674129397153.png

 

Here are my Measures for reference:

Timeliness (Batch) % =

VAR Delayed = [Delayed Deliveries (Batch)]
var Total = [Total Deliveries (Batch)]
var result = IF(ISBLANK(Delayed), 0, IF(Total <> 0, DIVIDE(Delayed, Total)))

RETURN
IF(Total < 1 , BLANK(),
    IF( Delayed > 0 , 0 , 1 - result)
)
 
 
T Batch =
VAR Delayed = [Delayed Deliveries (Batch)]
var Total = [Total Deliveries (Batch)]

RETURN
AVERAGEX('1_delivered_files', 1-DIVIDE(Delayed, Total))

 

0 REPLIES 0

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.