Primary string expression

Discuss how to create custom stats, reports and HUD profiles and share your creations.

Moderators: WhiteRider, kraada, Flag_Hippo, morny, Moderators

Primary string expression

Postby petemctailor » Wed Jun 07, 2017 1:37 pm

Hello

I need to create many custom stats, and it takes a long time to copy expressions and change the columns to "format type".

I would like to know the original expression, so that automatically the program adjusts the expression of "format type" with "Value expression", as the following example:

Value expression:
Code: Select all
Columna_2


Format type (manually changing the expression):
Code: Select all
format( '{1}', if ( columna_2 >0 and columna_2 <100, format('({1})', format_number(columna_2, 0, false, false)), '' ) )


Format type (without changing "This" by "columna_2"):
Code: Select all
format( '{1}', if ( this >0 and this <100, format('({1})', format_number(this, 0, false, false)), '' ) )


With the latter "format type" I don't have to copy the column and replace it with "this", which saves me a lot of copy/past time.


The question:

How do I play the last "format type" to avoid changing the expression manually in the next case?

Value expression:
Code: Select all
(Columna_1/columna_2) * 100


Format type:
Code: Select all
if((columna_1 / columna_2) * 100 >= 99,99, format_number( (columna_1 / columna_2) * 100 , 2 , false , false ))



Logically replacing the columns with "This" does not work, I think I should use strings as in the first example (format( '{1} {2}',).....

But I can't create the right expression, is it so kind to expose a complete example plz?
petemctailor
 
Posts: 34
Joined: Sun Feb 19, 2017 7:07 pm

Re: Primary string expression

Postby petemctailor » Wed Jun 07, 2017 1:42 pm

Graphic example, the first screenshot is the one that does not work and I want to be able to use without having to edit the expression in "format type".

Thanks a lot.
Attachments
2.PNG
It doesn't work
2.PNG (7.53 KiB) Viewed 932 times
3.PNG
Work
3.PNG (7.85 KiB) Viewed 932 times
1.PNG
Work
1.PNG (8.04 KiB) Viewed 932 times
petemctailor
 
Posts: 34
Joined: Sun Feb 19, 2017 7:07 pm

Re: Primary string expression

Postby WhiteRider » Thu Jun 08, 2017 2:30 am

"this" will be replaced by the whole Value Expression, so "this/this" doesn't make sense. That would be "((Columna_1/columna_2) * 100) / ((Columna_1/columna_2) * 100)".

You can use the Value Expression from your example 1 and the Format Type from example 2.
WhiteRider
Moderator
 
Posts: 53984
Joined: Sat Jan 19, 2008 7:06 pm
Location: UK

Re: Primary string expression

Postby rubencash » Thu Jun 08, 2017 12:02 pm

Sure, when there are more than 1 column I understand "this" does not work, but there is nothing that can replace it?

I was thinking of something like:
Code: Select all
format('{1} {2}', if(( {1} / {2}) * 100 >= 99,99, format_number( ( {1} / {2} ) * 100 , 2 , false , false ))


I'm sorry to be stubborn, thank you.
rubencash
 
Posts: 153
Joined: Thu Aug 22, 2013 3:23 pm

Re: Primary string expression

Postby WhiteRider » Thu Jun 08, 2017 2:16 pm

You can use "this" for multiple columns - it will replace the full expression. What you can't do with "this" is access parts of the expression.

So "this" can be "(a / b) * 100", but you can't access "a" or "b" using "this", only the full "(a / b) * 100".

e.g. You can do this:

format('{1}', if( this >= 99, 99, format_number( this, 2 , false , false )))
WhiteRider
Moderator
 
Posts: 53984
Joined: Sat Jan 19, 2008 7:06 pm
Location: UK

Re: Primary string expression

Postby rubencash » Fri Jun 09, 2017 8:03 pm

Great, so I can understand " format (' {1} ' " is not necessary in this expression, correct? Or would there be any reason to include it?

Thank you very much, all settled.
rubencash
 
Posts: 153
Joined: Thu Aug 22, 2013 3:23 pm

Re: Primary string expression

Postby WhiteRider » Mon Jun 12, 2017 2:15 am

Probably not in this case - it depends exactly what you want to display.
WhiteRider
Moderator
 
Posts: 53984
Joined: Sat Jan 19, 2008 7:06 pm
Location: UK


Return to Custom Stats, Reports and HUD Profiles

Who is online

Users browsing this forum: No registered users and 19 guests

cron
highfalutin