Skip navigation
Currently Being Moderated

How to filter 2D array in Flex and perform computation based on Filtering

May 3, 2013 2:02 AM

Tags: #as3 #flex #actionscript

I have an array as follows:

Asia     India   Calcutta 100 200 
Asia     India   Chennai  200 400
Asia     India   Mumbai   100 300
Asia     PAK     XXXXXX   100 300
Asia     PAK     SSSSSS   200 100
Americas Canada  Ottawa   200 200
Americas Canada  Toronto  120 200
Americas Mexico  Sonoro   110 500

I need to filter the above dataset also calculating the sum of each region by the use of a specific filter such as a region name is given.(eg. Asia)

Output for filter Asia must give me :

India   400 900 
300 400

How is this possible in Flex array 2D.

  • Currently Being Moderated
    May 4, 2013 4:20 AM   in reply to Rohini_1327

    Use the example array as the input to a function and create the second array as the output.


    Loop through the first array finding the unique country names for the filter region, then for each country name, sum entries for that country, then add a row for the country to the output array.

    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points