📜 ⬆️ ⬇️

QlikView. Conditional Formatting "Like Excel"

The task is to make the conditional formatting of the table "as in Excel". QlikView does quite well with the standard coloring tasks according to the condition, but dynamically choosing the parameters, and also like in Excel - the question “how is it at all ..?” Arose.
Bottom line: there were several implementation options, several versions, a considerable amount of time was spent on testing and debugging. Refactoring of the finished implementation was carried out. I present the final version that meets the needs of the customer, tested and verified.

Functional task (statement)


There is a table in which measurements and expressions are selected dynamically, the formulas for calculating the values ​​themselves are simple: sums, averages, relative percentages, absolute values, and the like.

It is required to allow the user to color the table depending on the selected parameters. Key introductory - one column should be able to colorize with different colors, that is, multi-coloring, according to different parameters. The second key is to be able to color the field depending on another “interrelated parameters”, for example, we color the “amount of purchases” depending on the value “average price of products on the market”.
The following is the main part of the implementation. I will not dwell on such moments as hiding / closing the menu, creating lists, and the like. If you have questions about the details, I will tell you in addition.
')
The final result, the path to which was thorny:



Block 1. Data preparation for the function menu


The code prepares the foundation for the menu lists described in block 3
tColorsFormatListSelection: LOAD * INLINE [%ColorDisplayNameFormat      n   n%  n   n%     ]; tFilterTypeListSelection: LOAD * INLINE [%FilterDisplayNameType    ]; tColorsTableList: LOAD*INLINE [%ColorDisplayName|%ColorRGBValue|%SortColorList -| RGB(192,0,0)|1 | RGB(255,0,0)|2 | RGB(255,192,0)|3 | RGB(255,255,0)|4 -| RGB(146,208,80)|5 | RGB(0,176,80)|6 -| RGB(0,176,240)|7 | RGB(0,112,192)|8 -| RGB(0,32,96)|9 | RGB(112,48,160)|10 ](delimiter is '|'); tColorFieldsListSelectionRelation: Load [ Qlik] AS %ColorFieldName, [/] AS %ExpressionType D:\QLIK\Data\Mapped_fields.xlsx (ooxml, embedded labels, table is [MetaField]) WHERE Match([/],'',''); tColorFieldsListSelectionClause: Load [ Qlik] AS %ColorFieldNameClause, [/] AS %ExpressionTypeClause FROM D:\QLIK\Data\Mapped_fields.xlsx (ooxml, embedded labels, table is [MetaField]) WHERE Match([/],''); 


I also needed to create several dozen variables:



vColorFormatString - compiled string

vColorFormatString1 ... 10 - designed to parse a string from vColorFormatString into 10 parameters for absolute values , I made this limitation, my opinion is that you no longer need this, in general, this restriction is purely ideological and you can increase the number of parameters for a short time.

vColorFormatStringPerc1… 10 - designed to parse a string from vColorFormatString into 10 parameters for relative values ​​(percentages)

vColorFormat1… 10 - colors

Block 2. Development of the functional menu1




Purpose:

  1. Displays the current list of created parameters by the user.
  2. Ability to remove any conditional formatting option
  3. Calls up the menu for selecting conditional formatting options.

Let us dwell on two elements below.

The first is the display of the currently created parameters.

This area is a text object that displays the currently created parameters based on the parsing string. And now the first brick of this whole action:

Text display formula
 = SubField(TextBetween(vColorFormatString,'||','||',1),'|',1) & '' & If(SubField(TextBetween(vColorFormatString,'||','||',1),'|',1) = SubField(TextBetween(vColorFormatString,'||','||',1),'|',2),'', SubField(TextBetween(vColorFormatString,'||','||',1),'|',2)) & ' ('& SubField(TextBetween(vColorFormatString,'||','||',1),'|',4) & ' '& If( Index(SubField(TextBetween(vColorFormatString,'||','||',1),'|',2),'%')>0 OR Index(SubField(TextBetween(vColorFormatString,'||','||',1),'|',4),'%')>0, If(WildMatch( SubField(TextBetween(vColorFormatString,'||','||',1),'|',4),'**'),'', num($(=SubField(TextBetween(vColorFormatString,'||','||',1),'|',5)),'# ##0,00')) & ' % '& If(WildMatch( SubField(TextBetween(vColorFormatString,'||','||',1),'|',6),'*Empty*'),'', num($(=SubField(TextBetween(vColorFormatString,'||','||',1),'|',6)),'# ##0,00')&' %') , If(WildMatch( SubField(TextBetween(vColorFormatString,'||','||',1),'|',4),'**'),'', num($(=SubField(TextBetween(vColorFormatString,'||','||',1),'|',5)),'# ##0.0')) & ' '& If(WildMatch( SubField(TextBetween(vColorFormatString,'||','||',1),'|',6),'*Empty*'),SubField(%EdName,',',1), num($(=SubField(TextBetween(vColorFormatString,'||','||',1),'|',6)),'# ##0.0')& ' ' &SubField(%EdName,',',1) ) )& ')' 


Horror some, right? :)

Now I think it became clear to many that all the logic is implemented on a text string. Collected a line - sorted out a line!

The string assembly is

|| RWA% | RWA% | RGB (255,0,0) | Above average | num (vColorFormatValue1 / 100, '# ## 0,00') | Empty
|| CODE% | CODE% | RGB (255,0,0) | Below average | num (vColorFormatValue1 / 100, '# ## 0,00') | Empty
|| GCD% | GCD% | RGB (255,0,0) | Below average | num (vColorFormatValue1 / 100, '# ## 0,00') | Empty
|| RORWA% | RORWA% | RGB (255,0,0) | Below average | round (num (124.63), 0.0001) | Empty
|| EL% | EL% | RGB (255,255,0) | Above average | round (num (124.62), 0.0001) | Empty
|| EL% | EL% | RGB (0.176.80) | Below average | round (num (124.62), 0.0001) | Empty
|| OD% | OD% | RGB (0,112,192) | Below average | round (num (124.62), 0.0001) | Empty
||

Parse the string

|| What is Beauty | By what way | Color | Condition | Value1 | Value2

SubField indexes (TextBetween (vColorFormatString, '||', '||', 1), '|', 4) - the expression of each parameter is highlighted with '||' '||', the property of the expression is separated by a single '|' thus indexes 1 and 4 say to take the first block of parameters and from it the fourth value.

Two values ​​(Value1, Value2) for the parameter “between”.

Let's go further ...

Deletion of the parameter is essentially “replicate” the values ​​in the string.

Execution code for deleting a conditional formatting parameter
=Replace(vColorFormatString, '||' & TextBetween(vColorFormatString,'||','||',1),'')

Block 3. Development of the functional menu2


Picture1


Picture2


Picture3


The main menu of the collection of parameters. Again, I will not dwell on the elements of the lists and descriptions of their logic of hiding closure.

The main logic for our line, the collection of all that the user has clicked on in this menu is sewn up on the “ready” button.

The action “set variable” is vColorFormatString, code:
 =If( SubStringCount(vColorFormatString,'||')<11 AND ( (vColorParamByClause=0 AND ( (Len(GetFieldSelections(%ColorFieldName))>0 AND Len(GetFieldSelections(%ColorFieldNameClause))>0) AND (GetFieldSelections(%ColorFieldName) <> GetFieldSelections(%ColorFieldNameClause)) )) OR (vColorParamByClause=1 AND Len(GetFieldSelections(%ColorFieldNameClause))>0) ), If(vColorParamByClause=0, if(len(vColorFormatString)<1, '||' & Trim(GetFieldSelections(%ColorFieldName,'|',50)) &'|' & Trim(GetFieldSelections(%ColorFieldNameClause,'|',50)) &'|' & $(=only({<%ColorDisplayName={"$(=SubField(concat(%ColorDisplayName,',',%SortColorList),',',1))"}>}%ColorRGBValue)) &'|'& GetFieldSelections(%ColorDisplayNameFormat,'|',1) & '|'& vColorFormatValue1Transform & '|'& If(GetFieldSelections(%ColorDisplayNameFormat,1) ='', vColorFormatValue2Transform,'Empty') & '||', vColorFormatString & Trim(GetFieldSelections(%ColorFieldName,'|',50)) &'|' & Trim(GetFieldSelections(%ColorFieldNameClause,'|',50)) &'|' & $(=only({<%ColorDisplayName={"$(=SubField(concat(%ColorDisplayName,',',%SortColorList),',',1))"}>}%ColorRGBValue)) &'|'& GetFieldSelections(%ColorDisplayNameFormat,'|',1) & '|'& vColorFormatValue1Transform & '|'& If(GetFieldSelections(%ColorDisplayNameFormat,1) ='', vColorFormatValue2Transform,'Empty') &'||' ) , if(len(vColorFormatString)<1, '||' & Trim(GetFieldSelections(%ColorFieldNameClause,'|',50)) &'|' & Trim(GetFieldSelections(%ColorFieldNameClause,'|',50)) &'|' & $(=only({<%ColorDisplayName={"$(=SubField(concat(%ColorDisplayName,',',%SortColorList),',',1))"}>}%ColorRGBValue)) &'|'& GetFieldSelections(%ColorDisplayNameFormat,'|',1) & '|'& vColorFormatValue1Transform & '|'& If(GetFieldSelections(%ColorDisplayNameFormat,1) ='', vColorFormatValue2Transform,'Empty') & '||', vColorFormatString & Trim(GetFieldSelections(%ColorFieldNameClause,'|',50))&'|' & Trim(GetFieldSelections(%ColorFieldNameClause,'|',50)) &'|' & $(=only({<%ColorDisplayName={"$(=SubField(concat(%ColorDisplayName,',',%SortColorList),',',1))"}>}%ColorRGBValue)) &'|'& GetFieldSelections(%ColorDisplayNameFormat,'|',1) & '|'& vColorFormatValue1Transform & '|'& If(GetFieldSelections(%ColorDisplayNameFormat,1) ='', vColorFormatValue2Transform,'Empty') &'||' ) ), vColorFormatString ) 


Block 5. We parse the text.


The code for vColorFormatString1 variables ... 10.

The key point for each of the 10 variables is changing the index for SubField SubField (TextBetween (vColorFormatString, '||', '||', 1 ) - vColorFormatString 1 , index 1.

For vColorFormatString 4 - respectively
SubField (TextBetween (vColorFormatString, '||', '||', 4 )

Absolute Parsing Variable Code
 =If(Len(SubField(TextBetween(vColorFormatString,'||','||',4),'|',4))>0, Pick(Match(SubField(TextBetween(vColorFormatString,'||','||',4),'|',4) ,'','','','',' n ',' n%',' n ',' n%',' ',' '), // 'round(sum(['& Trim(SubField(TextBetween(vColorFormatString,'||','||',4),'|',2)) &'])/$(=%Value),1)' & '>' & $(='SubField(TextBetween(vColorFormatString,'&chr(39)&'||'&chr(39)&','&chr(39)&'||'&chr(39)&',4),'&chr(39)&'|'&chr(39)&',5)'), // 'round(sum(['& Trim(SubField(TextBetween(vColorFormatString,'||','||',4),'|',2)) &'])/$(=%Value),1)' & '<' & $(='SubField(TextBetween(vColorFormatString,'&chr(39)&'||'&chr(39)&','&chr(39)&'||'&chr(39)&',4),'&chr(39)&'|'&chr(39)&',5)'), // 'round(sum(['& Trim(SubField(TextBetween(vColorFormatString,'||','||',4),'|',2)) &'])/$(=%Value),1)' & '>' & $(='SubField(TextBetween(vColorFormatString,'&chr(39)&'||'&chr(39)&','&chr(39)&'||'&chr(39)&',4),'&chr(39)&'|'&chr(39)&',5)') &' AND '& 'round(sum(['& Trim(SubField(TextBetween(vColorFormatString,'||','||',4),'|',2)) &'])/$(=%Value),1)' & '<' & $(='SubField(TextBetween(vColorFormatString,'&chr(39)&'||'&chr(39)&','&chr(39)&'||'&chr(39)&',4),'&chr(39)&'|'&chr(39)&',6)'), // 'round(sum(DISTINCT ['& Trim(SubField(TextBetween(vColorFormatString,'||','||',4),'|',2)) &'])/$(=%Value),1)' & '=' & $(='SubField(TextBetween(vColorFormatString,'&chr(39)&'||'&chr(39)&','&chr(39)&'||'&chr(39)&',4),'&chr(39)&'|'&chr(39)&',5)'), // n  'num(rank(if(round(sum(['& Trim(SubField(TextBetween(vColorFormatString,'||','||',4),'|',2)) &'])/$(=%Value),1)>0, sum(['& Trim(SubField(TextBetween(vColorFormatString,'||','||',4),'|',2)) &']))/$(=%Value),1))' & '<=' & $(='SubField(TextBetween(vColorFormatString,'&chr(39)&'||'&chr(39)&','&chr(39)&'||'&chr(39)&',4),'&chr(39)&'|'&chr(39)&',5)'), // n% '100-((sum(['& Trim(SubField(TextBetween(vColorFormatString,'||','||',4),'|',2)) &']) / SUM( TOTAL ['& Trim(SubField(TextBetween(vColorFormatString,'||','||',4),'|',2)) &']))*100) < ' & '100-' & $(='SubField(TextBetween(vColorFormatString,'&chr(39)&'||'&chr(39)&','&chr(39)&'||'&chr(39)&',4),'&chr(39)&'|'&chr(39)&',5)') , // n  'num(rank(if(round(sum(['& Trim(SubField(TextBetween(vColorFormatString,'||','||',4),'|',2)) &'])/$(=%Value),1)>0, -sum(['& Trim(SubField(TextBetween(vColorFormatString,'||','||',4),'|',2)) &']))/$(=%Value),1))' & '<=' & $(='SubField(TextBetween(vColorFormatString,'&chr(39)&'||'&chr(39)&','&chr(39)&'||'&chr(39)&',4),'&chr(39)&'|'&chr(39)&',5)'), // n% '((sum(['& Trim(SubField(TextBetween(vColorFormatString,'||','||',4),'|',2)) &']) / SUM( TOTAL ['& Trim(SubField(TextBetween(vColorFormatString,'||','||',4),'|',2)) &']))*100) < ' & $(='SubField(TextBetween(vColorFormatString,'&chr(39)&'||'&chr(39)&','&chr(39)&'||'&chr(39)&',4),'&chr(39)&'|'&chr(39)&',5)'), //  'sum(DISTINCT ['& Trim(SubField(TextBetween(vColorFormatString,'||','||',4),'|',2)) &'])>= Median(TOTAL <$(vGroupByList)> ['& Trim(SubField(TextBetween(vColorFormatString,'||','||',4),'|',2)) &'])', //  'sum(DISTINCT ['& Trim(SubField(TextBetween(vColorFormatString,'||','||',4),'|',2)) &'])<= Median(TOTAL <$(vGroupByList)> ['& Trim(SubField(TextBetween(vColorFormatString,'||','||',4),'|',2)) &'])' ),'0>1') 


For the percentage of the content is more complicated
 =If(Len(SubField(TextBetween(vColorFormatString,'||','||',2),'|',4))>0 AND $(='WildMatch('& chr(39) & SubField(TextBetween(vColorFormatString,'||','||',2),'|',2)&chr(39) & ',' &chr(39)&'EL %'&chr(39) &',' &chr(39)&' %'&chr(39) &',' &chr(39)&' %'&chr(39) &',' &chr(39)&' %'&chr(39) &','& chr(39)&'RWA %'&chr(39) &','& chr(39)&'RWA%(RORWA)'&chr(39) &','& chr(39)&'RORWA%'&chr(39) &')')>0, Pick(Match(SubField(TextBetween(vColorFormatString,'||','||',2),'|',4) ,'','','','',' n ',' n%',' n ',' n%',' ',' '), // Pick($(='WildMatch('& chr(39) & SubField(TextBetween(vColorFormatString,'||','||',2),'|',2)&chr(39) & ',' &chr(39)&'EL %'&chr(39) &',' &chr(39)&' %'&chr(39) &',' &chr(39)&' %'&chr(39) &',' &chr(39)&' %'&chr(39) &','& chr(39)&'RWA %'&chr(39) &','& chr(39)&'RWA%(RORWA)'&chr(39) &','& chr(39)&'RORWA%'&chr(39) &')'), '$(vELPercFormula)','$(vNODPercFormula)','$(vODPercFormula)','$(vKODPercFormula)','$(vRWAPercFormula)','$(vRWAPercRORWAFormula)','$(vRORWAPercFormula)') & '>' & $(='SubField(TextBetween(vColorFormatString,'&chr(39)&'||'&chr(39)&','&chr(39)&'||'&chr(39)&',2),'&chr(39)&'|'&chr(39)&',5)'), // Pick($(='WildMatch('& chr(39) & SubField(TextBetween(vColorFormatString,'||','||',2),'|',2)&chr(39) & ',' &chr(39)&'EL %'&chr(39) &',' &chr(39)&' %'&chr(39) &',' &chr(39)&' %'&chr(39) &',' &chr(39)&' %'&chr(39) &','& chr(39)&'RWA %'&chr(39) &','& chr(39)&'RWA%(RORWA)'&chr(39) &','& chr(39)&'RORWA%'&chr(39) &')'), '$(vELPercFormula)','$(vNODPercFormula)','$(vODPercFormula)','$(vKODPercFormula)','$(vRWAPercFormula)','$(vRWAPercRORWAFormula)','$(vRORWAPercFormula)') & '<' & $(='SubField(TextBetween(vColorFormatString,'&chr(39)&'||'&chr(39)&','&chr(39)&'||'&chr(39)&',2),'&chr(39)&'|'&chr(39)&',5)'), // Pick($(='WildMatch('& chr(39) & SubField(TextBetween(vColorFormatString,'||','||',2),'|',2)&chr(39) & ',' &chr(39)&'EL %'&chr(39) &',' &chr(39)&' %'&chr(39) &',' &chr(39)&' %'&chr(39) &',' &chr(39)&' %'&chr(39) &','& chr(39)&'RWA %'&chr(39) &','& chr(39)&'RWA%(RORWA)'&chr(39) &','& chr(39)&'RORWA%'&chr(39) &')'), '$(vELPercFormula)','$(vNODPercFormula)','$(vODPercFormula)','$(vKODPercFormula)','$(vRWAPercFormula)','$(vRWAPercRORWAFormula)','$(vRORWAPercFormula)') & '>' & $(='SubField(TextBetween(vColorFormatString,'&chr(39)&'||'&chr(39)&','&chr(39)&'||'&chr(39)&',2),'&chr(39)&'|'&chr(39)&',5)') &' AND '& Pick($(='WildMatch('& chr(39) & SubField(TextBetween(vColorFormatString,'||','||',2),'|',2)&chr(39) & ',' &chr(39)&'EL %'&chr(39) &',' &chr(39)&' %'&chr(39) &',' &chr(39)&' %'&chr(39) &',' &chr(39)&' %'&chr(39) &','& chr(39)&'RWA %'&chr(39) &','& chr(39)&'RWA%(RORWA)'&chr(39) &','& chr(39)&'RORWA%'&chr(39) &')'), '$(vELPercFormula)','$(vNODPercFormula)','$(vODPercFormula)','$(vKODPercFormula)','$(vRWAPercFormula)','$(vRWAPercRORWAFormula)','$(vRORWAPercFormula)') & '<' & $(='SubField(TextBetween(vColorFormatString,'&chr(39)&'||'&chr(39)&','&chr(39)&'||'&chr(39)&',2),'&chr(39)&'|'&chr(39)&',6)'), // Pick($(='WildMatch('& chr(39) & SubField(TextBetween(vColorFormatString,'||','||',2),'|',2)&chr(39) & ',' &chr(39)&'EL %'&chr(39) &',' &chr(39)&' %'&chr(39) &',' &chr(39)&' %'&chr(39) &',' &chr(39)&' %'&chr(39) &','& chr(39)&'RWA %'&chr(39) &','& chr(39)&'RWA%(RORWA)'&chr(39) &','& chr(39)&'RORWA%'&chr(39) &')'), '$(vELPercFormula)','$(vNODPercFormula)','$(vODPercFormula)','$(vKODPercFormula)','$(vRWAPercFormula)','$(vRWAPercRORWAFormula)','$(vRORWAPercFormula)') & '=' & $(='SubField(TextBetween(vColorFormatString,'&chr(39)&'||'&chr(39)&','&chr(39)&'||'&chr(39)&',2),'&chr(39)&'|'&chr(39)&',5)'), // n  Pick($(='WildMatch('& chr(39) & SubField(TextBetween(vColorFormatString,'||','||',2),'|',2)&chr(39) & ',' &chr(39)&'EL %'&chr(39) &',' &chr(39)&' %'&chr(39) &',' &chr(39)&' %'&chr(39) &',' &chr(39)&' %'&chr(39) &','& chr(39)&'RWA %'&chr(39) &','& chr(39)&'RWA%(RORWA)'&chr(39) &','& chr(39)&'RORWA%'&chr(39) &')'), 'num(rank($(vELPercFormula),1))','num(rank($(vNODPercFormula),1))','num(rank($(vODPercFormula),1))','num(rank($(vKODPercFormula),1))','num(rank($(vRWAPercFormula),1))','num(rank($(vRWAPercRORWAFormula),1))','num(rank($(vRORWAPercFormula),1))') & '<=' & $(='SubField(TextBetween(vColorFormatString,'&chr(39)&'||'&chr(39)&','&chr(39)&'||'&chr(39)&',2),'&chr(39)&'|'&chr(39)&',5)'), // n% Pick($(='WildMatch('& chr(39) & SubField(TextBetween(vColorFormatString,'||','||',2),'|',2)&chr(39) & ',' &chr(39)&'EL %'&chr(39) &',' &chr(39)&' %'&chr(39) &',' &chr(39)&' %'&chr(39) &',' &chr(39)&' %'&chr(39) &','& chr(39)&'RWA %'&chr(39) &','& chr(39)&'RWA%(RORWA)'&chr(39) &','& chr(39)&'RORWA%'&chr(39) &')'), '$(vELPercFormula)','$(vNODPercFormula)','$(vODPercFormula)','$(vKODPercFormula)','$(vRWAPercFormula)','$(vRWAPercRORWAFormula)','$(vRORWAPercFormula)') & ' < 100-' & $(='SubField(TextBetween(vColorFormatString,'&chr(39)&'||'&chr(39)&','&chr(39)&'||'&chr(39)&',2),'&chr(39)&'|'&chr(39)&',5)') , // n  Pick($(='WildMatch('& chr(39) & SubField(TextBetween(vColorFormatString,'||','||',2),'|',2)&chr(39) & ',' &chr(39)&'EL %'&chr(39) &',' &chr(39)&' %'&chr(39) &',' &chr(39)&' %'&chr(39) &',' &chr(39)&' %'&chr(39) &','& chr(39)&'RWA %'&chr(39) &','& chr(39)&'RWA%(RORWA)'&chr(39) &','& chr(39)&'RORWA%'&chr(39) &')'), 'num(rank(-$(vELPercFormula),1))','num(rank(-$(vNODPercFormula),1))','num(rank(-$(vODPercFormula),1))','num(rank(-$(vKODPercFormula),1))','num(rank(-$(vRWAPercFormula),1))','num(rank(-$(vRWAPercRORWAFormula),1))','num(rank(-$(vRORWAPercFormula),1))') & '<=' & $(='SubField(TextBetween(vColorFormatString,'&chr(39)&'||'&chr(39)&','&chr(39)&'||'&chr(39)&',2),'&chr(39)&'|'&chr(39)&',5)'), // n% Pick($(='WildMatch('& chr(39) & SubField(TextBetween(vColorFormatString,'||','||',2),'|',2)&chr(39) & ',' &chr(39)&'EL %'&chr(39) &',' &chr(39)&' %'&chr(39) &',' &chr(39)&' %'&chr(39) &',' &chr(39)&' %'&chr(39) &','& chr(39)&'RWA %'&chr(39) &','& chr(39)&'RWA%(RORWA)'&chr(39) &','& chr(39)&'RORWA%'&chr(39) &')'), '$(vELPercFormula)','$(vNODPercFormula)','$(vODPercFormula)','$(vKODPercFormula)','$(vRWAPercFormula)','$(vRWAPercRORWAFormula)','$(vRORWAPercFormula)') & ' < ' & $(='SubField(TextBetween(vColorFormatString,'&chr(39)&'||'&chr(39)&','&chr(39)&'||'&chr(39)&',2),'&chr(39)&'|'&chr(39)&',5)'), //  Pick($(='WildMatch('& chr(39) & SubField(TextBetween(vColorFormatString,'||','||',2),'|',2)&chr(39) & ',' &chr(39)&'EL %'&chr(39) &',' &chr(39)&' %'&chr(39) &',' &chr(39)&' %'&chr(39) &',' &chr(39)&' %'&chr(39) &','& chr(39)&'RWA %'&chr(39) &','& chr(39)&'RWA%(RORWA)'&chr(39) &','& chr(39)&'RORWA%'&chr(39) &')'), 'round($(vELPercFormula),0.0001) > round($(vELPercTOTALFormula),0.0001)', 'round($(vNODPercFormula),0.0001) > round($(vNODPercTOTALFormula),0.0001)', 'round($(vODPercFormula),0.0001) > round($(vODPercTOTALFormula),0.0001)', 'round($(vKODPercFormula),0.0001) > round($(vKODPercTOTALFormula),0.0001)', 'round($(vRWAPercFormula),0.0001) > round($(vRWAPercTOTALFormula),0.0001)', 'round($(vRWAPercRORWAFormula),0.0001) > round($(vRWAPercRORWAFormulaTotal),0.0001)', 'round($(vRORWAPercFormula),0.0001) > round($(vRORWAPercTotalFormula),0.0001)'), //  Pick($(='WildMatch('& chr(39) & SubField(TextBetween(vColorFormatString,'||','||',2),'|',2)&chr(39) & ',' &chr(39)&'EL %'&chr(39) &',' &chr(39)&' %'&chr(39) &',' &chr(39)&' %'&chr(39) &',' &chr(39)&' %'&chr(39) &','& chr(39)&'RWA %'&chr(39) &','& chr(39)&'RWA%(RORWA)'&chr(39) &','& chr(39)&'RORWA%'&chr(39) &')'), 'round($(vELPercFormula),0.0001) < round($(vELPercTOTALFormula),0.0001)', 'round($(vNODPercFormula),0.0001) < round($(vNODPercTOTALFormula),0.0001)', 'round($(vODPercFormula),0.0001) < round($(vODPercTOTALFormula),0.0001)', 'round($(vKODPercFormula),0.0001) < round($(vKODPercTOTALFormula),0.0001)', 'round($(vRWAPercFormula),0.0001) < round($(vRWAPercTOTALFormula),0.0001)', 'round($(vRWAPercRORWAFormula),0.0001) < round($(vRWAPercRORWAFormulaTotal),0.0001)', 'round($(vRORWAPercFormula),0.0001) < round($(vRORWAPercTotalFormula),0.0001)') ),'0>1') 


The difference is that I also stitched the formulas of relative values ​​into variables and substituted them depending on the content of the string. It did not work differently or did not always work stably, it was considered crooked ... In general, initially absolute and relative values ​​were in one parsing variable and it was hellishly cumbersome, searching for code errors or calculations, parsing what was written was almost impossible. Therefore, it was decided to divide - absolute parsim in some variables, percentage in others.

Block 6. Add settings to the table


Well and most importantly, now we need to paint the table on the basis of what we have distributed, the code for all fields of the table is identical, except for the input condition for naming the field, so we had to manually fill the whole thing, no automation, more precisely, about 15 columns, automatism produced in the muscles of the fingers, develops muscle memory. Further

for example, for the “CRM ID” field of the table, the code is
 if(Match('CRM ID',SubField(TextBetween(vColorFormatString,'||','||',1),'|',1)) AND ($(vColorFormatString1) OR $(vColorFormatStringPerc1)),$(vColorFormat1), If(Match('CRM ID',SubField(TextBetween(vColorFormatString,'||','||',2),'|',1)) AND ($(vColorFormatString2) OR $(vColorFormatStringPerc2)),$(vColorFormat2), If(Match('CRM ID',SubField(TextBetween(vColorFormatString,'||','||',3),'|',1)) AND ($(vColorFormatString3) OR $(vColorFormatStringPerc3)),$(vColorFormat3), If(Match('CRM ID',SubField(TextBetween(vColorFormatString,'||','||',4),'|',1)) AND ($(vColorFormatString4) OR $(vColorFormatStringPerc4)),$(vColorFormat4), If(Match('CRM ID',SubField(TextBetween(vColorFormatString,'||','||',5),'|',1)) AND ($(vColorFormatString5) OR $(vColorFormatStringPerc5)),$(vColorFormat5), If(Match('CRM ID',SubField(TextBetween(vColorFormatString,'||','||',6),'|',1)) AND ($(vColorFormatString6) OR $(vColorFormatStringPerc6)),$(vColorFormat6), If(Match('CRM ID',SubField(TextBetween(vColorFormatString,'||','||',7),'|',1)) AND ($(vColorFormatString7) OR $(vColorFormatStringPerc7)),$(vColorFormat7), If(Match('CRM ID',SubField(TextBetween(vColorFormatString,'||','||',8),'|',1)) AND ($(vColorFormatString8) OR $(vColorFormatStringPerc8)),$(vColorFormat8), If(Match('CRM ID',SubField(TextBetween(vColorFormatString,'||','||',9),'|',1)) AND ($(vColorFormatString9) OR $(vColorFormatStringPerc9)),$(vColorFormat9), If(Match('CRM ID',SubField(TextBetween(vColorFormatString,'||','||',10),'|',1)) AND ($(vColorFormatString10) OR $(vColorFormatStringPerc10)),$(vColorFormat10), )))))))))) 


for example, for the “AMOUNT” field of the table, the code is
 if(Match('AMOUNT',SubField(TextBetween(vColorFormatString,'||','||',1),'|',1)) AND ($(vColorFormatString1) OR $(vColorFormatStringPerc1)),$(vColorFormat1), If(Match('AMOUNT',SubField(TextBetween(vColorFormatString,'||','||',2),'|',1)) AND ($(vColorFormatString2) OR $(vColorFormatStringPerc2)),$(vColorFormat2), If(Match('AMOUNT',SubField(TextBetween(vColorFormatString,'||','||',3),'|',1)) AND ($(vColorFormatString3) OR $(vColorFormatStringPerc3)),$(vColorFormat3), If(Match('AMOUNT',SubField(TextBetween(vColorFormatString,'||','||',4),'|',1)) AND ($(vColorFormatString4) OR $(vColorFormatStringPerc4)),$(vColorFormat4), If(Match('AMOUNT',SubField(TextBetween(vColorFormatString,'||','||',5),'|',1)) AND ($(vColorFormatString5) OR $(vColorFormatStringPerc5)),$(vColorFormat5), If(Match('AMOUNT',SubField(TextBetween(vColorFormatString,'||','||',6),'|',1)) AND ($(vColorFormatString6) OR $(vColorFormatStringPerc6)),$(vColorFormat6), If(Match('AMOUNT',SubField(TextBetween(vColorFormatString,'||','||',7),'|',1)) AND ($(vColorFormatString7) OR $(vColorFormatStringPerc7)),$(vColorFormat7), If(Match('AMOUNT',SubField(TextBetween(vColorFormatString,'||','||',8),'|',1)) AND ($(vColorFormatString8) OR $(vColorFormatStringPerc8)),$(vColorFormat8), If(Match('AMOUNT',SubField(TextBetween(vColorFormatString,'||','||',9),'|',1)) AND ($(vColorFormatString9) OR $(vColorFormatStringPerc9)),$(vColorFormat9), If(Match('AMOUNT',SubField(TextBetween(vColorFormatString,'||','||',10),'|',1)) AND ($(vColorFormatString10) OR $(vColorFormatStringPerc10)),$(vColorFormat10), )))))))))) 


On this, in general, everything. If you describe each element of the menu, you get a complete book, like a training manual. So sorry if someone did not have enough details.

PS
I understand that most likely it could have been done more elegantly, but when you are already in the process, then only the chips fly. I did not really want to describe all the details of the implementation of the menu, and why not. By and large, the article is intended to show how you can do it, maybe someone will inspire, a cooler idea of ​​implementation will appear.

Source: https://habr.com/ru/post/446076/


All Articles