Forum Discussion
Double lookup for value
- Anonymous6 years ago
The problem i had could be tackeled by using these:
VAR lookupinlaattemplower = CALCULATE( MAX('Isentrope coefficient(k)'[Temp(k)]); FILTER(ALL('Isentrope coefficient(k)'[Temp(k)]);'Isentrope coefficient(k)'[Temp(k)] < inlaattemp))VAR lookupinlaatdruklower = CALCULATE( MAX('Isentrope coefficient(k)'[Druk(a)]); FILTER(ALL('Isentrope coefficient(k)'[Druk(a)]);'Isentrope coefficient(k)'[Druk(a)] < inlaatdruk))And to lookup with double value:
VAR isentropeinlaatlowertemplowerdruk = LOOKUPVALUE('Isentrope coefficient(k)'[IsentropeCoefficient];'Isentrope coefficient(k)'[Temp(k)];lookupinlaattemplower;'Isentrope coefficient(k)'[Druk(a)];lookupinlaatdruklower)
For people looking to do bilinear interpolation this is my final solution:isentropecoefficient = //Declaring variables. VAR inlaattemp = SELECTEDVALUE('Gemeten parameters'[Inlaattemp(k)]) VAR uitlaattemp = SELECTEDVALUE('Gemeten parameters'[Uitlaattemp(k)]) VAR inlaatdruk = SELECTEDVALUE('Gemeten parameters'[Inlaatdruk(a)]) VAR uitlaatdruk = SELECTEDVALUE('Gemeten parameters'[Uitlaatdruk(a)]) //Stappen in tabel VAR deltax = 5 VAR deltay = 5 //Calculating values in lookuptable lower then measured value. //Inlaat VAR lookupinlaattemplower = CALCULATE( MAX('Isentrope coefficient(k)'[Temp(k)]); FILTER(ALL('Isentrope coefficient(k)'[Temp(k)]);'Isentrope coefficient(k)'[Temp(k)] < inlaattemp)) VAR lookupinlaatdruklower = CALCULATE( MAX('Isentrope coefficient(k)'[Druk(a)]); FILTER(ALL('Isentrope coefficient(k)'[Druk(a)]);'Isentrope coefficient(k)'[Druk(a)] < inlaatdruk)) //Uitlaat VAR lookupuitlaattemplower = CALCULATE( MAX('Isentrope coefficient(k)'[Temp(k)]); FILTER(ALL('Isentrope coefficient(k)'[Temp(k)]);'Isentrope coefficient(k)'[Temp(k)] < uitlaattemp)) VAR lookupuitlaatdruklower = CALCULATE( MAX('Isentrope coefficient(k)'[Druk(a)]); FILTER(ALL('Isentrope coefficient(k)'[Druk(a)]);'Isentrope coefficient(k)'[Druk(a)] < uitlaatdruk)) //Calculating values in lookuptable higher then measured value. //Inlaat VAR lookupinlaattemphigher = CALCULATE( MIN('Isentrope coefficient(k)'[Temp(k)]); FILTER(ALL('Isentrope coefficient(k)'[Temp(k)]);'Isentrope coefficient(k)'[Temp(k)] > inlaattemp)) VAR lookupinlaatdrukhigher = CALCULATE( MIN('Isentrope coefficient(k)'[Druk(a)]); FILTER(ALL('Isentrope coefficient(k)'[Druk(a)]);'Isentrope coefficient(k)'[Druk(a)] > inlaatdruk)) //Uitlaat VAR lookupuitlaattemphigher = CALCULATE( MIN('Isentrope coefficient(k)'[Temp(k)]); FILTER(ALL('Isentrope coefficient(k)'[Temp(k)]);'Isentrope coefficient(k)'[Temp(k)] > uitlaattemp)) VAR lookupuitlaatdrukhigher = CALCULATE( MIN('Isentrope coefficient(k)'[Druk(a)]); FILTER(ALL('Isentrope coefficient(k)'[Druk(a)]);'Isentrope coefficient(k)'[Druk(a)] > uitlaatdruk)) //Looking up the isentrope in lookup table. //Inlaat VAR isentropeinlaatlowertemplowerdruk = LOOKUPVALUE('Isentrope coefficient(k)'[IsentropeCoefficient];'Isentrope coefficient(k)'[Temp(k)];lookupinlaattemplower;'Isentrope coefficient(k)'[Druk(a)];lookupinlaatdruklower) VAR isentropeinlaatlowertemphigherdruk = LOOKUPVALUE('Isentrope coefficient(k)'[IsentropeCoefficient];'Isentrope coefficient(k)'[Temp(k)];lookupinlaattemplower;'Isentrope coefficient(k)'[Druk(a)];lookupinlaatdrukhigher) VAR isentropeinlaathighertemplowerdruk = LOOKUPVALUE('Isentrope coefficient(k)'[IsentropeCoefficient];'Isentrope coefficient(k)'[Temp(k)];lookupinlaattemphigher;'Isentrope coefficient(k)'[Druk(a)];lookupinlaatdruklower) VAR isentropeinlaathighertemphigherdruk = LOOKUPVALUE('Isentrope coefficient(k)'[IsentropeCoefficient];'Isentrope coefficient(k)'[Temp(k)];lookupinlaattemphigher;'Isentrope coefficient(k)'[Druk(a)];lookupinlaatdrukhigher) //Uitlaat VAR isentropeuitlaatlowertemplowerdruk = LOOKUPVALUE('Isentrope coefficient(k)'[IsentropeCoefficient];'Isentrope coefficient(k)'[Temp(k)];lookupuitlaattemplower;'Isentrope coefficient(k)'[Druk(a)];lookupuitlaatdruklower) VAR isentropeuitlaatlowertemphigherdruk = LOOKUPVALUE('Isentrope coefficient(k)'[IsentropeCoefficient];'Isentrope coefficient(k)'[Temp(k)];lookupuitlaattemplower;'Isentrope coefficient(k)'[Druk(a)];lookupuitlaatdrukhigher) VAR isentropeuitlaathighertemplowerdruk = LOOKUPVALUE('Isentrope coefficient(k)'[IsentropeCoefficient];'Isentrope coefficient(k)'[Temp(k)];lookupuitlaattemphigher;'Isentrope coefficient(k)'[Druk(a)];lookupuitlaatdruklower) VAR isentropeuitlaathighertemphigherdruk = LOOKUPVALUE('Isentrope coefficient(k)'[IsentropeCoefficient];'Isentrope coefficient(k)'[Temp(k)];lookupuitlaattemphigher;'Isentrope coefficient(k)'[Druk(a)];lookupuitlaatdrukhigher) //X1_VAL = lowerdruk Y1_VAL = lowertemp //F11 = lowertemplowerdruk F21= lowertemphigherdruk F12= highertemplowerdruk F22=highertemphigherdruk VAR inlaatG1 = ((lookupinlaatdruklower + deltax - inlaatdruk) * isentropeinlaatlowertemplowerdruk + (inlaatdruk - lookupinlaatdruklower) * isentropeinlaatlowertemphigherdruk) / deltax VAR inlaatG2 = ((lookupinlaatdruklower + deltax - inlaatdruk) * isentropeinlaathighertemplowerdruk + (inlaatdruk - lookupinlaatdruklower) * isentropeinlaathighertemphigherdruk) / deltax VAR Interpolate_BL = ((lookupinlaattemplower + deltay - inlaattemp) * inlaatG1 + (inlaattemp - lookupinlaattemplower) * inlaatG2) / deltay RETURN //Checking if pressure is in bound. IF( OR( MAX('Gemeten parameters'[Inlaatdruk(a)]) < MIN('Isentrope coefficient(k)'[Druk(a)]); MIN('Gemeten parameters'[Inlaatdruk(a)]) > MAX('Isentrope coefficient(k)'[Druk(a)])) ;"Error Druk valt niet binnen lookup table."; //Checking if temperature is in bound. IF( OR( MAX('Gemeten parameters'[Inlaattemp(k)]) < MIN('Isentrope coefficient(k)'[Temp(k)]); MIN('Gemeten parameters'[Inlaattemp(k)]) > MAX('Isentrope coefficient(k)'[Temp(k)]));"Error Temperatuur valt niet binnen lookup table"; //Rest van code Interpolate_BL ) )
kentyler
Thanks, but im not quite sure you understand what i mean.
The lookup table has no id's.
In case of storing i could store the selected ID, Temperature and pressure (1, 283 and 61)
Then i would have to lookup the closes value of Temperature BELOW 283 and the one ABOVE 283 (280 and 285 in the example)
Same for Pressure.
Then i need to use the Below values to get a number (1,343) and the above numbers to get the value (1.354) i believe this could be achieved with a filter statement indeed.
My problem lays in finding the closest value above and below.
Wait its actually pretty easy!
If i use:
CALCULATE(
MAX('Isentrope coefficient(k)'[Temp(k)]);
FILTER(ALL('Isentrope coefficient(k)'[Temp(k)]);'Isentrope coefficient(k)'[Temp(k)] < inlaattemp))
I could use the same with MIN and a > filter. You guys helped me very well 🙂
I now have the Higher and lower values and im going to try to filter out the Isentrope
Thanks again!
(i will post my full solution for Bilinear Interpolation when im fully done in this topic for other people to find)
- Anonymous6 years agoNot applicable
The problem i had could be tackeled by using these:
VAR lookupinlaattemplower = CALCULATE( MAX('Isentrope coefficient(k)'[Temp(k)]); FILTER(ALL('Isentrope coefficient(k)'[Temp(k)]);'Isentrope coefficient(k)'[Temp(k)] < inlaattemp))VAR lookupinlaatdruklower = CALCULATE( MAX('Isentrope coefficient(k)'[Druk(a)]); FILTER(ALL('Isentrope coefficient(k)'[Druk(a)]);'Isentrope coefficient(k)'[Druk(a)] < inlaatdruk))And to lookup with double value:
VAR isentropeinlaatlowertemplowerdruk = LOOKUPVALUE('Isentrope coefficient(k)'[IsentropeCoefficient];'Isentrope coefficient(k)'[Temp(k)];lookupinlaattemplower;'Isentrope coefficient(k)'[Druk(a)];lookupinlaatdruklower)
For people looking to do bilinear interpolation this is my final solution:isentropecoefficient = //Declaring variables. VAR inlaattemp = SELECTEDVALUE('Gemeten parameters'[Inlaattemp(k)]) VAR uitlaattemp = SELECTEDVALUE('Gemeten parameters'[Uitlaattemp(k)]) VAR inlaatdruk = SELECTEDVALUE('Gemeten parameters'[Inlaatdruk(a)]) VAR uitlaatdruk = SELECTEDVALUE('Gemeten parameters'[Uitlaatdruk(a)]) //Stappen in tabel VAR deltax = 5 VAR deltay = 5 //Calculating values in lookuptable lower then measured value. //Inlaat VAR lookupinlaattemplower = CALCULATE( MAX('Isentrope coefficient(k)'[Temp(k)]); FILTER(ALL('Isentrope coefficient(k)'[Temp(k)]);'Isentrope coefficient(k)'[Temp(k)] < inlaattemp)) VAR lookupinlaatdruklower = CALCULATE( MAX('Isentrope coefficient(k)'[Druk(a)]); FILTER(ALL('Isentrope coefficient(k)'[Druk(a)]);'Isentrope coefficient(k)'[Druk(a)] < inlaatdruk)) //Uitlaat VAR lookupuitlaattemplower = CALCULATE( MAX('Isentrope coefficient(k)'[Temp(k)]); FILTER(ALL('Isentrope coefficient(k)'[Temp(k)]);'Isentrope coefficient(k)'[Temp(k)] < uitlaattemp)) VAR lookupuitlaatdruklower = CALCULATE( MAX('Isentrope coefficient(k)'[Druk(a)]); FILTER(ALL('Isentrope coefficient(k)'[Druk(a)]);'Isentrope coefficient(k)'[Druk(a)] < uitlaatdruk)) //Calculating values in lookuptable higher then measured value. //Inlaat VAR lookupinlaattemphigher = CALCULATE( MIN('Isentrope coefficient(k)'[Temp(k)]); FILTER(ALL('Isentrope coefficient(k)'[Temp(k)]);'Isentrope coefficient(k)'[Temp(k)] > inlaattemp)) VAR lookupinlaatdrukhigher = CALCULATE( MIN('Isentrope coefficient(k)'[Druk(a)]); FILTER(ALL('Isentrope coefficient(k)'[Druk(a)]);'Isentrope coefficient(k)'[Druk(a)] > inlaatdruk)) //Uitlaat VAR lookupuitlaattemphigher = CALCULATE( MIN('Isentrope coefficient(k)'[Temp(k)]); FILTER(ALL('Isentrope coefficient(k)'[Temp(k)]);'Isentrope coefficient(k)'[Temp(k)] > uitlaattemp)) VAR lookupuitlaatdrukhigher = CALCULATE( MIN('Isentrope coefficient(k)'[Druk(a)]); FILTER(ALL('Isentrope coefficient(k)'[Druk(a)]);'Isentrope coefficient(k)'[Druk(a)] > uitlaatdruk)) //Looking up the isentrope in lookup table. //Inlaat VAR isentropeinlaatlowertemplowerdruk = LOOKUPVALUE('Isentrope coefficient(k)'[IsentropeCoefficient];'Isentrope coefficient(k)'[Temp(k)];lookupinlaattemplower;'Isentrope coefficient(k)'[Druk(a)];lookupinlaatdruklower) VAR isentropeinlaatlowertemphigherdruk = LOOKUPVALUE('Isentrope coefficient(k)'[IsentropeCoefficient];'Isentrope coefficient(k)'[Temp(k)];lookupinlaattemplower;'Isentrope coefficient(k)'[Druk(a)];lookupinlaatdrukhigher) VAR isentropeinlaathighertemplowerdruk = LOOKUPVALUE('Isentrope coefficient(k)'[IsentropeCoefficient];'Isentrope coefficient(k)'[Temp(k)];lookupinlaattemphigher;'Isentrope coefficient(k)'[Druk(a)];lookupinlaatdruklower) VAR isentropeinlaathighertemphigherdruk = LOOKUPVALUE('Isentrope coefficient(k)'[IsentropeCoefficient];'Isentrope coefficient(k)'[Temp(k)];lookupinlaattemphigher;'Isentrope coefficient(k)'[Druk(a)];lookupinlaatdrukhigher) //Uitlaat VAR isentropeuitlaatlowertemplowerdruk = LOOKUPVALUE('Isentrope coefficient(k)'[IsentropeCoefficient];'Isentrope coefficient(k)'[Temp(k)];lookupuitlaattemplower;'Isentrope coefficient(k)'[Druk(a)];lookupuitlaatdruklower) VAR isentropeuitlaatlowertemphigherdruk = LOOKUPVALUE('Isentrope coefficient(k)'[IsentropeCoefficient];'Isentrope coefficient(k)'[Temp(k)];lookupuitlaattemplower;'Isentrope coefficient(k)'[Druk(a)];lookupuitlaatdrukhigher) VAR isentropeuitlaathighertemplowerdruk = LOOKUPVALUE('Isentrope coefficient(k)'[IsentropeCoefficient];'Isentrope coefficient(k)'[Temp(k)];lookupuitlaattemphigher;'Isentrope coefficient(k)'[Druk(a)];lookupuitlaatdruklower) VAR isentropeuitlaathighertemphigherdruk = LOOKUPVALUE('Isentrope coefficient(k)'[IsentropeCoefficient];'Isentrope coefficient(k)'[Temp(k)];lookupuitlaattemphigher;'Isentrope coefficient(k)'[Druk(a)];lookupuitlaatdrukhigher) //X1_VAL = lowerdruk Y1_VAL = lowertemp //F11 = lowertemplowerdruk F21= lowertemphigherdruk F12= highertemplowerdruk F22=highertemphigherdruk VAR inlaatG1 = ((lookupinlaatdruklower + deltax - inlaatdruk) * isentropeinlaatlowertemplowerdruk + (inlaatdruk - lookupinlaatdruklower) * isentropeinlaatlowertemphigherdruk) / deltax VAR inlaatG2 = ((lookupinlaatdruklower + deltax - inlaatdruk) * isentropeinlaathighertemplowerdruk + (inlaatdruk - lookupinlaatdruklower) * isentropeinlaathighertemphigherdruk) / deltax VAR Interpolate_BL = ((lookupinlaattemplower + deltay - inlaattemp) * inlaatG1 + (inlaattemp - lookupinlaattemplower) * inlaatG2) / deltay RETURN //Checking if pressure is in bound. IF( OR( MAX('Gemeten parameters'[Inlaatdruk(a)]) < MIN('Isentrope coefficient(k)'[Druk(a)]); MIN('Gemeten parameters'[Inlaatdruk(a)]) > MAX('Isentrope coefficient(k)'[Druk(a)])) ;"Error Druk valt niet binnen lookup table."; //Checking if temperature is in bound. IF( OR( MAX('Gemeten parameters'[Inlaattemp(k)]) < MIN('Isentrope coefficient(k)'[Temp(k)]); MIN('Gemeten parameters'[Inlaattemp(k)]) > MAX('Isentrope coefficient(k)'[Temp(k)]));"Error Temperatuur valt niet binnen lookup table"; //Rest van code Interpolate_BL ) )