Forum Discussion

Syndicate_Admin's avatar
Syndicate_Admin
Administrator
3 years ago
Solved

Calculate mode from a data table

Nice day.

I have a historical data table with which I have calculated the average and median but I lack fashion. I've been searching different forums and haven't found the solution. I would be very grateful for your recommendations.

Attached part of the table that is required to calculate the time mode for each sub activity:

SUB ACTIVITYTIME
Contracts, agreements and legal documents0:10:00
Contracts, agreements and legal documents0:10:00
Meeting with supplier0:15:00
Payment process0:15:00
Quote0:15:00
Payment process0:15:00
Review and filling of WBS, requisitions0:15:00
Contracts, agreements and legal documents0:15:00
Quote0:15:00
Contracts, agreements and legal documents0:30:00
Contracts, agreements and legal documents0:30:00
Purchase Order0:30:00
Quote0:30:00
Validation and specification0:30:00
Modify Ms Project program1:15:00
Ms Project Program Review / Activities1:30:00
Ms Project Program Review3:30:00
Design/draw/model5:40:00
Purchase Order0:15:00
Purchase Order0:15:00
Purchase Order0:15:00
Guarantees0:15:00
Guarantees0:15:00
Validation and specification0:15:00
Purchase Order0:20:00
Purchase Order0:20:00
Purchase Order0:20:00
Payment process0:30:00
Comparative0:45:00
Validation and specification0:45:00
Validation and specification0:45:00
Updating indicators1:00:00
Validation and specification1:30:00
Quote1:30:00
Updating indicators1:30:00
Ms Project Program Review2:45:00
Ms Project Program Review3:00:00
Printing/Folding Drawings4:00:00
Plano as-built4:00:00
Architectural program and zoning8:00:00
Design/draw/model8:00:00
Quantification/Catalog/WBS8:00:00
Design/draw/model9:00:00
Design/draw/model9:00:00
Quote0:15:00
Contracts, agreements and legal documents0:15:00
Purchase Order0:15:00
Purchase Order0:15:00
Purchase Order0:15:00
Payment process0:15:00
Job closure0:20:00
Job closure0:25:00
Quote0:25:00
Quote0:25:00
Payment process0:30:00
Comparative0:30:00
Quote0:30:00
Contracts, agreements and legal documents0:35:00
Comparative0:40:00
Validation and specification0:45:00
Contracts, agreements and legal documents0:45:00
Quote1:00:00
Validation and specification1:00:00
Construction route1:00:00
CONSTRUCTION SUPERVISION2:00:00
Development of generators and volumetries2:00:00
ELABORATION OF MATERIAL REQUIREMENTS2:00:00
Site visit2:00:00
Purchase tracking2:00:00
DELIVERY TO OPERATION3:00:00
Printing/Folding Drawings3:00:00
DELIVERY TO OPERATION5:00:00
Project request (interiors/engineering)5:00:00
Design/draw/model5:00:00
Design bases/criteria5:00:00
Design/draw/model7:00:00
Review and filling of WBS, requisitions0:05:00
Review and filling of WBS, requisitions0:05:00
Review and filling of WBS, requisitions0:05:00
Review and filling of WBS, requisitions0:05:00
Review and filling of WBS, requisitions0:05:00
Review and filling of WBS, requisitions0:05:00
Review and filling of WBS, requisitions0:05:00
Review and filling of WBS, requisitions0:05:00
Review and filling of WBS, requisitions0:05:00
Review and filling of WBS, requisitions0:05:00
Quote0:10:00
Quote0:10:00
Quote0:10:00
Quote0:10:00

Thank you.

  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi Syndicate_Admin 

    You just can remove the column I have put in measure, than the output is correct

    Best Regards!

    Yolo Zhu

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

6 Replies

  • Syndicate_Admin , Based on what I got. You have convert time to second or minute and take avg

    seconds  = hour([Time])*3600 + minute([Time])*3600  + Second([Time])

     

    You can use median or medianx

     

    median measure= medianx(Table, Table[second])

     

    if needed convert back to time

     

    time(0,0,0) + [median measure]/3600*24

    • Syndicate_Admin's avatar
      Syndicate_Admin
      Administrator

      Thank you amitchandak, I understand that this solution you propose gives as an answer to the median.

      But the data I need is fashion, which is the value that is most repeated.

      Best regards.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Syndicate_Admin 

     the following is my sample,

    1.  create a new column to transfer the time to minutes

    Minutes_TIME = HOUR('Table'[TIME])*60+MINUTE('Table'[TIME])

    2.Then create two measures: 

    AVG_TIME = AVERAGEX(FILTER(ALL('Table'),[SUB ACTIVITY]=MAX('Table'[SUB ACTIVITY])),[Minutes_TIME]) 
    MED_TIME = MEDIANX(FILTER(ALL('Table'),[SUB ACTIVITY]=MAX('Table'[SUB ACTIVITY])),[Minutes_TIME]) 

    Output:

    Best Regards!

    Yolo Zhu

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    Calculate mode from a data table.pbix33 KB
    • Syndicate_Admin's avatar
      Syndicate_Admin
      Administrator

      Thank you Yolo Zhu, I understand that this solution you propose gives as a response to the average and the median.

      But the data I need is fashion, which is the value that is most repeated.

      Best regards.

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi Syndicate_Admin 

        You just can remove the column I have put in measure, than the output is correct

        Best Regards!

        Yolo Zhu

        If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

         

  • As a complement to the help I require, it is like having a table with the following data:

    NationalityAge
    Mexico25
    Mexico15
    Mexico30
    Mexico30
    Mexico20
    Colombia22
    Colombia35
    Colombia40
    Colombia40
    Colombia50
    Argentina18
    Argentina21
    Argentina45
    Argentina45
    Argentina33
    Canada16
    Canada22
    Canada28
    Canada28
    Canada34

    And that as a result the following summary table:

    NationalityFashion (age)
    Mexico30
    Colombia40
    Argentina45
    Canada28