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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
TcT85
Helper III
Helper III

DAX - Get the highest Median value from multiple columns.

Could anyone please help me create the dax formula.

 

Is there a way to get the highest median value from multiple products for a product/date?

 

ProductSerialnumberDateTimeMachine 1Machine 2Machine 3Machine 4Machine 5Machine 6
A111112024-05-0309:20:0116227577
A111122024-05-0310:20:0115210688
A111132024-05-0311:20:0116116577
A111142024-05-0312:20:0115218688
A111152024-05-0313:20:0116110577
A111162024-05-0314:20:0114211688
A111172024-05-0315:20:0117112577
A111182024-05-0316:20:0115211688
A111192024-05-0317:20:0116112577
A111202024-05-0318:20:0115213688
A111212024-05-0319:20:0113135577
A111222024-05-0320:20:0115225688
A111232024-05-0321:20:0116114577
          
          
          
   Median15213577
          
   Highest Median15     

 

I'm in need of 2 following visualisation:

1. Highest median per product.

2. Highest median per product over a time period like weeks.

1 ACCEPTED SOLUTION
Gabry
Responsive Resident
Responsive Resident

Alright, if you prefer not to unpivot the columns (which might not be the best approach anyway), you can proceed as follows:

1)Create a measure for each machine that calculates the median, like this:

 

machine1Median = MEDIAN('Table (3)'[Machine 1])
machine2Median = MEDIAN('Table (3)'[Machine 2])

 

...and so on, for each machine you have.

 

2)Then, to find the maximum of the medians, you can use the following formula:

 

maxmedian = MAXX(
UNION(
SUMMARIZE('Table (3)', 'Table (3)'[Product], "Median", [machine1Median]),
SUMMARIZE('Table (3)', 'Table (3)'[Product], "Median", [machine2Median])

 

(...and so on, for each machine you have)


),
[Median]
)

 

3)Lastly, you can display the products and their corresponding maximum median in a table visual


 

View solution in original post

6 REPLIES 6
TcT85
Helper III
Helper III

Gabry, thank you for your support, it works as intended.

Gabry
Responsive Resident
Responsive Resident

Hello,

isn't as easy as:

 

MedianProduct = Maxx(Productstable, yourmedianformula)

HI Gabry,

 

How would you write the median formula? 😅

Gabry
Responsive Resident
Responsive Resident

It depends on how is set up your model. Why do you have machines in the columns, is your data set that way?

If so you should unpivot those columns before calculate the median. 

If that was just the visualization but the data it's not in that format the formula should look like this

MedianFormula = calculate(median(table[values]), all(products))

 

This formula calculates the median of the values in the "values" column, disregarding any filters applied to the "products" table.

Hi Gabry,

 

The data is set that way.

The product goes through 5 machines and we get the machine time for each machine.

We need to find the highest median time to be able to create a tact time..

Gabry
Responsive Resident
Responsive Resident

Alright, if you prefer not to unpivot the columns (which might not be the best approach anyway), you can proceed as follows:

1)Create a measure for each machine that calculates the median, like this:

 

machine1Median = MEDIAN('Table (3)'[Machine 1])
machine2Median = MEDIAN('Table (3)'[Machine 2])

 

...and so on, for each machine you have.

 

2)Then, to find the maximum of the medians, you can use the following formula:

 

maxmedian = MAXX(
UNION(
SUMMARIZE('Table (3)', 'Table (3)'[Product], "Median", [machine1Median]),
SUMMARIZE('Table (3)', 'Table (3)'[Product], "Median", [machine2Median])

 

(...and so on, for each machine you have)


),
[Median]
)

 

3)Lastly, you can display the products and their corresponding maximum median in a table visual


 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.