Skip to main content
Announcements
July 15, NEW Customer Portal: Initial launch will improve how you submit Support Cases. IMPORTANT DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
PradeepReddy
Specialist II
Specialist II

Median Calculation

Hi,

I had a simple requirement, but not getting the solution. May be missing something..

Scenario:

There is 3 fields in one table.(Fields: Firm_Name, Time_Period, Hours). I want to calculate the Median of the Hours and correponding Firm_Name.

Dimension : Time_Period

Expressions: Median, Firm_Name( corresponding to the Median value)

Functionality:

If the count is Odd number then there is no issue.--- Median(Hours)

If the count is Even then, the median value doesn't match to any existing Hours value. So I am not able to display the Firm_Name. So I want to  dispaly the middle 2 values and its correposnding Firm_Name.

Ex: 6,9,2,5,10,7 (After sorting... 2,5,6,7,9,10)

     Here I want to display the values 6 & 7 and its coresponding Firm_Name.

Thanks in advance..

9 Replies
rbecher
MVP
MVP

Hi,

I think Firm_Name should be a dimension? Or do I get something wrong?

- Ralf

Astrato.io Head of R&D
PradeepReddy
Specialist II
Specialist II
Author

Hi Ralf,


Dimension is Time_Period.

rbecher
MVP
MVP

Can you upload sample data and the expected result?

Astrato.io Head of R&D
PradeepReddy
Specialist II
Specialist II
Author

Here is the sample data...

Firm_NameHoursTime_Period
Firm112Period1
Firm210Period1
Firm414Period1
Firm945Period2
Firm1065Period2
Firm1133Period2
Firm1578Period2
Firm1287Period2
Firm1845Period2
Firm1970Period3
Firm2255Period3
Firm2376Period3

Expected output would be like below...

Time_PeriodMedianFirm Name
Period112Firm1
Period265
78
Firm10
Firm15
Period370Firm19

I am getting the result, If the count is Odd number. (using Median(), FieldIndex(), FieldValue()..)

But not getting for the Even count....

Thanks in advance..


rbecher
MVP
MVP

Please find attached solution. But the Median of Period2 = 55, so no match with a Firm!

- Ralf

Astrato.io Head of R&D
PradeepReddy
Specialist II
Specialist II
Author

Ralf,

thanks for your quick support....

yes you are right... that is the tricky one

IF Count(Hours) is odd , then it is straight forward.. no issue in this case...

    (in this case Median of Period2 should exists exists in the list of hours)

IF Count(Hours) is even, then we need to display the  Firm_Name of middle 2 values... as shown above.

    (in this case Median of Period2 may or may not exists in the list of hours)

Regards,

Pradeep

PradeepReddy
Specialist II
Specialist II
Author

Jagan Mohan

can you please help on this?

rbecher
MVP
MVP

Hi,

this is what I have so far. But it's not working for the upper middle (Period2=65). I think this is a set analysis isssue..

- Ralf

Astrato.io Head of R&D
PradeepReddy
Specialist II
Specialist II
Author

If we can achieve this  using set analysis, can you please assist me how to achieve this..?