Min & Max in nested Datagrids

Hi,

I have nested datagrids. The master one, called Questions, is a list of ... questions. The slave grid displays X possible answers for each question. Each answer is associated to a score.

For calculating a measure, I would need to sum all the possible Mins meaning the total score if, for each question, the answer providing the lowest score would be selected. And the same for the Maxs.

The table with answers is just made of the (idT1_AnswerList), the id of the question (T1_Qref), a possible full text answer (T1_Answer) and the associated score (T1_Score). It overall looks like this:

Any idea how I could do that in a simple way ?

Thank you

Fred

Hi @FredK_Trashmail,

I’m not sure what is your question. You don’t know how to access your child data for each master record?

Hi,

I am struggling to get Min and Max and would love to get t it with minimum coding as it is always a long trial and error exercise for me.
My thinking is, when child data is loaded into ${result}, to execute a small loop which for each T1_QRef create a small List, determine the Min and Max of the List and add it to a variable.
Before I fight my way doing this, I just wanted to make sure it is the right way.

Thank you

Fred

These might help you:


H,

Thank you for this but first I am facing super basic issues I have been fighting with ever since you sent the doc.

For clarity, let me restate what I want to achieve.
I have a simple table called T1PossibleAnswers as below:

The way to read this is that for each Q1Ref, there are a number of possible answers, each one attached to a score.

The ultimate objective is to have 2 numeric boxes. Box1 (value sumMin) shows the summed score of all possible worst answers (-700 here) and Box2 (value sumMax) the summed score of all possible best answers (+800 here).

.

I get an error: 'IEnumerable' does not contain a definition for 'T1Score'. I have tried everything I could find in doc and other posts but fail to understand why T1Score is not a sub result of getT1PossibleAnswersResult.

I circled back a similar issue I had, I get that there is something more fundamental I don't get but, after 7 hours, I am lacking ideas.

Thank you

Fred

The result is enumerable not single item.

This I understood but I thought it would be a collection of values, T1Score being a field. Any suggestion of what I could change ?

Hey @FredK_Trashmail,

Please read again my reply. You are trying to access a property of an item while this variable is collection.

Hi Enchev,

I did read your response and never take it lightly. I know now what I do wrong but fail to understand what I should be doing instead. Any example you can point me to ?

Best regards

Fred

getT1PossibleAnswers() will return IEnumerable<T>. You can loop this collection to assign the property you want:

foreach(var answer in getT1PossibleAnswersResult)
{
   answer.SomeProperty = SomeValue
}

Took me some time but finally got it. Thank you very much for your guidance

foreach(var answerContainer in getT1PossibleAnswersResult)
{
// check if T1Qref is first or has changed
if (currentT1Qref != answerContainer.T1Qref.Value) {

  //Adds the min and max value if T1QRef has changed
  sumMin = sumMin + tempMin;
  sumMax = sumMax + tempMax;
    
    // sets currentT1QRef
    currentT1Qref = answerContainer.T1Qref.Value;
    
    // sets tempMin and tempMax to first T1Score of current T1QRef
    tempMin = answerContainer.T1Score.Value;
    tempMax = answerContainer.T1Score.Value;
    
  }
else {

// Changes tempMin to newest min value if relevant
    if (tempMin > answerContainer.T1Score.Value) {
       tempMin = answerContainer.T1Score.Value;
    }  

// Changes tempMax to newest max value if relevant
    if (tempMax < answerContainer.T1Score.Value) {
       tempMax = answerContainer.T1Score.Value;
    }  

}
}

// Last loop item
if (currentT1Qref >= 0) {
sumMin = sumMin + tempMin;
sumMax = sumMax + tempMax;
}