Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago

Quartile calculation with multiple conditions

Hello All, 

I have searched for the solution on this, and I have tried multiple things. However, I have not been successful.  I am trying to calculate the quartile for Hours and Quantity in the below table.  The first five columns of the below snapshot is coming from the Asset table, Hours is coming from the Activity table, and Quantity is coming from the Delivery table.  Additionally, the visual is filtered by date (last 3 calendar months).

 

Condition: The assets should be evaluated on the Line of Bus and Category.  For example, for the first row, I am trying to see what quartile the 171 hours falls into based on the Operations Line of Bus and the Pickup Category.  For the last line, I am trying to see what quartile the 1,539 hours falls into and what quartile the quantity of 3,901,873 falls into based on Fuel Line of Bus and the Tractor Category 

 

My Power BI report currently contains columns A through I.  Columns J - K are not included and rows after 14 are not included.  The Hours Quart and Quant Quart, column H & I, is where I need assistance.

 

1ABCDEFGIJK
2Unit NumberRegionLine of BusinessUnit ClassCategorySum of HoursSum of QuantityHours QuartQuant Quart Helper
3MTR2023802CentralFuelPower UnitTractor1317.8122760114 FuelTractor
4MTR2023810CentralFuelPower UnitTractor1789.83144413.9944 FuelTractor
5MTR2023806CentralFuelPower UnitTractor1691.5814354834 FuelTractor
6MTR2023803CentralOperationsPower UnitTruck1347.4714060514 OperationsTruck
7MTR2023808CentralOperationsPower UnitTruck2179.6112113011 OperationsTruck
9MTR2023807CentralFuelPower UnitTractor584.3510039914 FuelTractor
10MTR2084703CentralFuelPower UnitTractor765.89790214 FuelTractor
11MTR2084704CentralFuelPower UnitTractor1627.949327224 FuelTractor
12MTR2023812CentralFuelPower UnitTractor1711.716569844 FuelTractor
13MTR2023809CentralFuelPower UnitTractor13515132024 FuelTractor
14MTR2023813CentralFuelPower UnitTractor1639.551481234 FuelTractor
15           
16  Unique1234    
17  FuelTractor1317.811627.941691.581789.83    
18  OperationsTruck125998.75130868135736.25140605    

 

On the above sample table from Excel, I used a helper column (cell K3 formula =D3&F3). 

The table below the data, starting on row 16, is the quartile table that I used for my Hours Quart and Quant Quart formulas.  This is only to help calculate the formulas in columns H & I

D17 formula is: QUARTILE.INC(IF($L$3:$L$13=$D16,$G$3:$G$13),E$15)

The formula used for Column H is:

IF(G3<=INDEX($E$16:$H$17,MATCH($L3,$D$16:$D$17,0),1),1,IF(G3<=INDEX($E$16:$H$17,MATCH($L3,$D$16:$D$17,0),2),2,IF(G3<=INDEX($E$16:$H$17,MATCH($L3,$D$16:$D$17,0),3),3,4)))

 

One additional aspect, the table in Power BI also includes filters for Region, Line of Business, and Category, shown in the below.  I am not sure if this would need to be incorporated in a dax formula.

 

I would greatly appreciate any guidance or assistance to incorporate this logic in Power BI.  Thanks!

 

7 Replies