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

Win a FREE 3 Day Ticket to FabCon Vienna. Apply now

Reply
dejanzoric
Frequent Visitor

Displaying the larger value between the sum and the Max value with a condition

Hi, I ran into a problem that I don't know how to solve, So I need help if anyone has an idea.

I'll try to describe what I'm doing to help you understand the problem. These are shipments in the post office.

 

More values appear in the database 1. One person can send multiple packages (Client ID - Multiple package IDs) 2. Several persons can send a combined package (multiple client IDs - one ID package)

 

Table 1: Example data

 ID  Code_ID  Criterion  Amount_ID  Amount_Code_ID 
 0024025005057  18480000375001  01_criterion 239.837350.110
 0024025005057  18480002364001  01_criterion 1.223.1661.198.186
 0024025005111  31440025191001  01_criterion 1.719354.398
 0024025005111  41450025338001  01_criterion 162.2053.175
 0024173003560  51961249242001  02_criterion 64.45622.259
 0024173003578  54921203295001  02_criterion 215.848189.222
 0024173003578  59891065502001  02_criterion 674.540201.903
 0024173003578  59891077907001  02_criterion 650.557465.491
 0024173003578  59891082440001  02_criterion 11.442.20111.850.952
 0024173003578  62010293763001  02_criterion 211.5417.332
 0024025004255  SSM26971  03_criterion 26.6827.107
 0024025004255  SSM27228  03_criterion 31.7782.901
 0024025004271  SSM27228  03_criterion 21.1865.243
 0024025004271  SSM27314  03_criterion 15.8894.718
 0024025004271  SSM27382  03_criterion 33.3777.222
 0024025004271  SSM27544  03_criterion 9.4895.287
 0024025004271  SSM378  03_criterion 18.4251.230
 0024025004271  SSM3825  03_criterion 23.2743.879
0022002080492SSM12593 04_SHIPMENT DELIVERED 34.99254.548
0022002080492SSM12596 04_SHIPMENT DELIVERED 20.338124.823
0022002084056SSM12596 04_SHIPMENT DELIVERED 443.486455.183
0022002084331SSM4705 04_SHIPMENT DELIVERED 23.093500.733
0024025004255SSM26971 05_total 26.6827.107
0024025004255SSM27228 05_total 31.7782.901
0024025004271SSM27228 05_total 21.1865.243
0024025004271SSM27314 05_total 15.8894.718
0024025004271SSM27382 05_total 33.3777.222
0024025004271SSM27544 05_total 9.4895.287
0024025004271SSM378 05_total 18.4251.230
0024025004271SSM3825 05_total 23.2743.879
002402500505718480000375001 05_total 239.837350.110
002402500505718480002364001 05_total 1.223.1661.198.186
002402500511131440025191001 05_total 1.719354.398
002402500511141450025338001 05_total 162.2053.175
002417300356051961249242001 05_total 64.45622.259
002417300357854921203295001 05_total 215.848189.222
002417300357859891065502001 05_total 674.540201.903
002417300357859891077907001 05_total 650.557465.491
002417300357859891082440001 05_total 11.442.20111.850.952
002417300357862010293763001 05_total 211.5417.332

 

 

Table 2: Description of columns

 ID PACKAGE SENDER ID 
 Code_ID PACKAGE ID
 Criterion CRITERIA WHY THE PACKAGE WAS RETURNED
 Amount_ID REPORTED AMOUNT
 Amount_Code_ID ESTIMATED AMOUNT

 

 

Table 3: The overview I want to achieve in Power Bi

 Criterion  Sum of Amount_ID  higher value  Participation 
 01_criterion                      1.626.927                  1.362.11010,28%
 02_criterion                   13.259.143               11.873.21189,61%
 03_criterion                         180.100                       14.3290,11%
 05_total                   15.066.169               13.249.650 

Participation - Is the ratio of higher value in 05_Total

 

Problem Description

 

I'm currently doing all of this in Excel. The database became huge (over 2 million rows) and the criteria grew to over 100, so manual calculation became too demanding for me.

 

Table 4: I currently do this via pivot in excel as follows

CriterionID Sum of Amount_ID  Max of Amount_Code_ID  higher value 
01_criterion00240250050571.463.0031.198.1861.198.186
01_criterion0024025005111163.924354.398163.924
02_criterion002417300356064.45622.25922.259
02_criterion002417300357813.194.68711.850.95211.850.952
03_criterion002402500425558.4607.1077.107
03_criterion0024025004271121.6397.2227.222
05_total002402500425558.4607.1077.107
05_total0024025004271121.6397.2227.222
05_total00240250050571.463.0031.198.1861.198.186
05_total0024025005111163.924354.398163.924
05_total002417300356064.45622.25922.259
05_total002417300357813.194.68711.850.95211.850.952

 

higher value: =+IF(Sum of Amount_ID>Max of Amount_Code_ID;Max of Amount_Code_ID;Sum of Amount_ID)

I need to take a higher value

Table 3 - I get from table 4 by summing Amount_ID and higher value by criteria

 

Note: There are multiple criteria, I only need to select the criteria that are required of me. The total is not a sum, because it may happen that the package is returned on several grounds, and then the amounts are doubled. For this reason, I have to report the total and I solved that, but now the total appears as a criterion. I don't know how to calculate the percentage, but so I tell him to put it in the ratio 01_criteria/05_Total ... (as in table 3 - Participation)

 

Thanks in advance for your help, any ideas would be great,

Dejan

1 REPLY 1
dejanzoric
Frequent Visitor

I apologize, now I see that I did not mention that I imported the model through Power Bi, that I created a view that has many more columns in accordance with the request. Above I listed only two columns (higher value and Participation) that I don't know how to solve

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.