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

Get Fabric certified for FREE! Don't miss your chance! Learn more

Reply
BillPoster
Frequent Visitor

Sum of Median

I have a table that shows median time for each operation (multiple operations) in  a matrix and this shows correctly. 
Measure

MedianX Of Operation = MEdianX(Values(Append1[Batch Number]),  CALCULATE(Sum(Append1[Duration (HOURS)])))


Now the issue i have is showing the total at the bottom of the column as the sum of all the median values in the column. However it gives the median value instead.  (As seen in the snipped image below) 


BillPoster_0-1653149698139.png

 

1 ACCEPTED SOLUTION
SpartaBI
Community Champion
Community Champion

@BillPoster it should be the other way arround. 
In order to get the sum of the middle step in the total you should use SUMX outside and inside the median.
Something like:

 

MedianX Of Operation = SUMX(Values(Append1[Batch Number]),  CALCULATE(MEDIAN(Append1[Duration (HOURS)])))

 

The problem is I don't understand how you got the right number per row with the sum, unless it's just one row for each batch number in the model table.
 


2022-05-19 17_30_22-Re_ Need help on DAX function with measure vs colu... - Microsoft Power BI Commu.png

Showcase Report – Contoso By SpartaBI


SpartaBI_3-1652115470761.png   SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Full-Logo11.png

View solution in original post

13 REPLIES 13
BillPoster
Frequent Visitor

A big thank you to SpartaBI for all his help on this, he worked out the answer and got the data showing as I wanted using the following measure. 

MedianX Of Operation = sumx(SUMMARIZE('Appended Months','Appended Months'[Area],'Appended Months'[Final Description]),Calculate(MEdianX(Values('Appended Months'[Batch Number]), CALCULATE(Sum('Appended Months'[Duration (HOURS)])))))
v-yalanwu-msft
Community Support
Community Support

Hi, @BillPoster ;

Is your problem solved? If so, kindly mark the proper reply as a solution to help others having the similar issue and close the case. If not, let me know and I'll try to help you further.


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi, Not yet, I am going to have a zoom chat with someone about this to see if we can figure it out this week. I will report back how it goes. 

v-yalanwu-msft
Community Support
Community Support

Hi, @BillPoster ,

I'm sorry that it is really difficult to understand the final result you want. The result you want cannot correspond with the data you provided above, so I can hardly understand your logic. It would be nice if you could share a simple example file and the result


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

v-yalanwu-msft
Community Support
Community Support

Hi, @BillPoster ;

You could create a measure.

Measure = SUMX(SUMMARIZE('Table',[Batch Number],[Operation Description],"value",[MedianX Of Operation]),[value])

The final show:

vyalanwumsft_0-1653357130045.png


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi, This just sums up all the values, rather than just the median values. 
In your image above you are showing job one 3 times and a median time of job one each time.  It has to show the median time for each Job only once. 

BillPoster
Frequent Visitor

Hi SpartaBI, Firstly thanks for taking the time to answer.

To explain the data a bit better

There are around 70 operations in total and Every batch has each of those operations completed on it. (There can be multiple instances of an operation being done for a batch before it is completed.)
As far as I am aware the measure sums up the values for each batch number then gives the median value for that operation. And this does work on a line by line basis, however I am trying to get a total of all median values as well as I would like to use this value in a graph as well. 

Your measure gives me incorrect median values for each operation and the total at the bottom also isn't showing what I want it to.  (To the left of the image is the description of each operation.)

BillPoster_1-1653199636322.png

 

 






 

 

@BillPosterI still don't quite understand your data. Maybe you could share the file? 
From what I can see now is that you have operation number on the rows.
If according to your data the per row is good so the total should represent the median of the rows you put in the matrix when you use MEDIANX. In this case it's Operation number and maybe this will work:

MedianX Of Operation = SUMX(Values(Append1[Operation Number]),  CALCULATE(MEDIAN(Append1[Duration (HOURS)])))

 Hard to say, cause didn't understand fully your model.

Data is confidential so cannot share in its present form however I have reworked a small sample but unable to attach file as my organisation does not allow me to share one drive link. 
Below is a sample of one part of the data.  
To try and break down a bit more.
We create an object and that object is made up of 3 parts in 3 areas.
A batch number is issued for each object and it is the same for all 3 parts of that object.
An order number is issued for each part of the object so a batch number has 3 order numbers assigned to it.
Operation Numbers are duplictaed as it is just the flow within that area 
Duration is the time accrued each time it is worked on.
Operation description is unique and not duplicated in any of the areas (However this is a calculated column in PowerBi as there has had to be some reworking of the data so there are no duplicated descriptions) 

So what i need is something that shows the median duration of Operation description  (The current measure I have works for this is a table)
I also need a measure that will work out the total of all the median values
So if  the median of Job one is 0.78 and median of job 2 is 0.95 and  median of job 3 0.77 it would show 2.5

 

Hopefully this is a bit clearer than mud 😀

 

Order NumberOperation No.Operation DescriptionDuration (HOURS)Op  DATEBatch Number
1000307200-0280Job Three0.59388888401-Oct-21333400
1000308000-0220Job One3.76833330301-Oct-21146500
1000308000-0220Job One3.75777774801-Oct-21146500
1000308000-0220Job One3.68833330401-Oct-21146500
1000308000-0220Job One3.49305552801-Oct-21146500
1000308000-0220Job One3.77555552501-Oct-21146500
1000308000-0220Job One3.61944441601-Oct-21146500
1000308100-0220Job One4.29166663201-Oct-21333000
1000308100-0220Job One4.29805552101-Oct-21333000
1000308100-0220Job One4.26583329901-Oct-21333000
1000308100-0220Job One4.22749996601-Oct-21333000
1000308100-0220Job One3.48444441601-Oct-21333000
1000308100-0220Job One3.62166663801-Oct-21333000
1000308100-0220Job One3.47611108301-Oct-21333000
1000308100-0220Job One3.48916663901-Oct-21333000
1000308100-0220Job One1.48888887701-Oct-21333000
1000308100-0220Job One3.3666666401-Oct-21333000
1000308100-0220Job One3.34249997301-Oct-21333000
1000308100-0220Job One3.31833330701-Oct-21333000
1000308100-0220Job One3.3116666401-Oct-21333000
1000308100-0220Job One3.35944441801-Oct-21333000
1000312200-0280Job Three2.16333331602-Oct-21147100
1000312200-0280Job Three2.08888887202-Oct-21147100
1000312200-0280Job Three2.1702777602-Oct-21147100
1000312200-0280Job Three2.15194442702-Oct-21147100
1000312400-0280Job Three0.51027777402-Oct-21333600
1000312400-0280Job Three2.50083331302-Oct-21333600
1000312400-0280Job Three2.58583331302-Oct-21333600
1000312500-0220Job One4.95472218308-Oct-21245200
1000312500-0220Job One0.29833333108-Oct-21245200
1000312500-0220Job One3.85555552508-Oct-21245200
1000312500-0220Job One3.63277774908-Oct-21245200
1000312500-0220Job One2.08472220608-Oct-21245200

 

@BillPosterStill don't understand the business :))
Can you share what is the desired result from your sample data?
For example I took all columns and a median of the hours and it looks like this:

SpartaBI_0-1653218819295.png
In the sample data it looks like each batch had one order number and one operation no. Not sure this is the real situation in your data.
Anyway, for the sample data, what is the visual you want to do and the desired result? 🙂

 

I want to show the sum of all the medians visible at the bottom of the Table. 
I also want to be able to show the sum of the median in a graph against an expected value. 
As it stands at the minute, If I show the data for Area 1 it works, but as soon as I add in data for area 2 or 3 it throws the graph data out. 
Area 2 selected Left is the Expected and right is the median total for all operations

BillPoster_0-1653290685584.png

 

As soon as I add another area it doesn't work.

BillPoster_1-1653290773408.png

 

This is replicated in the table as well, so with a filter for one area selected it works and as soon as you introduce another area it throws it all out. 

BillPoster_2-1653291002852.png

 

BillPoster_3-1653291028971.png

 


What little hair i had left is going quickly 😀

Could it be down to some of the data being reword in a calculated column?

@BillPoster I will pm you 🙂

SpartaBI
Community Champion
Community Champion

@BillPoster it should be the other way arround. 
In order to get the sum of the middle step in the total you should use SUMX outside and inside the median.
Something like:

 

MedianX Of Operation = SUMX(Values(Append1[Batch Number]),  CALCULATE(MEDIAN(Append1[Duration (HOURS)])))

 

The problem is I don't understand how you got the right number per row with the sum, unless it's just one row for each batch number in the model table.
 


2022-05-19 17_30_22-Re_ Need help on DAX function with measure vs colu... - Microsoft Power BI Commu.png

Showcase Report – Contoso By SpartaBI


SpartaBI_3-1652115470761.png   SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Full-Logo11.png

Helpful resources

Announcements
Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.