Calculation: create matrix from selected values of 2 multi select categories

Comments

6 comments

  • Rainer Grabowski

    The multi select category fields are returned as an array. So you can use a function:

    var weekday = @weekday; 
    var role = @Role ;
    var type = @Type;
    weekdays.map(function(e,i){return e + role[i] + type;}).join();

    or a for-loop:

    var weekday = @weekday; 
    var role = @Role ;
    var type = @Type;
    var result = [];
    for(i = 0; i < weekday.length; i++){
        arr.push(weekday[i] + role[i] + d);
    }
    result.join() 

    Rainer

    0
    Comment actions Permalink
  • Admin BVOT

    Rainer Grabowski thank you. but something not like my wish :( 

    i use your above code:

    var type = @Tần suất thực hiện
    if (type =="Hàng ngày")
    {type = "daily"}
    var weekday = @Thứ
    var role = @Dành cho (english)
    var result = [];
    for(i = 0; i < weekday.length; i++){
        result.push(weekday[i]  + role[i]+ type);
    }
    result.join() 

    but no luck with My output is 2mdaily,3adaily 

    Need Correct ouput = 2managerdaily,2freelancerdaily,3managerdaily,3freelancerdaily

    form 3 fields: 

    • my role (field calculation from multi category) = manager,freelancer
    • my type (single category) = daily
    • my weekday (Multi category field) = 2,3

    Please help, 

    thanks again

     

     

    0
    Comment actions Permalink
  • Rainer Grabowski
    var i,j,
    role = @Dành cho (english),
    weekday = @Thứ,
    type = @Tần suất thực hiện,
    type = type == "Hàng ngày" ? "daily" : type,
    result = [];
    for(i = 0; i < weekday.length; i++){
       for(j = 0; j < role.length; j++){
           result.push(weekday[i] + role[j] + type);
       }
    }
    result.join()
    0
    Comment actions Permalink
  • Admin BVOT

    Thank you Rainer Grabowski

    This output includes many small element but not correct ( desired result: 2managerdaily,2freelancerdaily,3managerdaily,3freelancerdaily)

     
    0
    Comment actions Permalink
  • Rainer Grabowski

    Check your code, for me it works

    0
    Comment actions Permalink
  • Admin BVOT

    super thank you

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk