Custom Stats Formatting

Forum for users that want to write their own custom queries against the PT database either via the Structured Query Language (SQL) or using the PT3 custom stats/reports interface.

Moderator: Moderators

Custom Stats Formatting

Postby degoor » Mon Nov 07, 2011 4:13 pm

I have made a few custom stats of mine and I included them in the "Overview" section of the default popup player statistics grid.

I have formated them as "/%.2f" and "Show Times/Opportunities"="True" but no times/opportunities are displayed.

When there is no data collected the native stats are displayed as "NA% (0/0)" and the custom ones stay "0%()".

What am I missing?
degoor
 
Posts: 18
Joined: Wed Sep 30, 2009 2:22 am

Re: Custom Stats Formatting

Postby stuart_gall » Mon Nov 07, 2011 4:20 pm

I am working on something similar, I wanted to GET the NA.
This is controlled in the stats FORMAT tab

Something like
if (your stat = 0, invalid_value, format(yourstat,decimals,false,false))
Causes NA when stat = 0
stuart_gall
 
Posts: 61
Joined: Mon Mar 22, 2010 7:46 am

Re: Custom Stats Formatting

Postby degoor » Mon Nov 07, 2011 8:40 pm

Ok, here is a sample expression that I put in both fields of the "Format" tab of the stat:

format( '{1}% ({2}/{3})', if(cnt_float_turn_opp=0, "NA", (cnt_float_turn / cnt_float_turn_opp) * 100), format_number(cnt_float_turn,0,false,false), format_number(cnt_float_turn_opp,0,false,false) )

cnt_float_turn_opp - opportunities column
cnt_float_turn - actions column

"Show Times/Opportunities" option in the "Configure HUD" I set to "False". Suffix "%" in configured in the HUD.

When cnt_float_turn_opp>0 I am getting some weird result in the popup grid like:

60.000000% (3/5)%
degoor
 
Posts: 18
Joined: Wed Sep 30, 2009 2:22 am

Re: Custom Stats Formatting

Postby WhiteRider » Tue Nov 08, 2011 5:17 am

You don't need to use that type of format mechanism - your format expression of /%.2f is fine, but you need to make sure that the Value Expression has the right structure.
It needs to be exactly:

(a / b) * 100

..where a and b are your column names. Note the spaces either side of the / and * but not between ( and a or b and ).
If you have your Value Expressions like that and the format expression as /%.2f (or a simple format_number, or even blank) then the Times/Opportunities HUD property should work.

If you still have problems please export your stat and attach it to a Support ticket so that we can investigate.
WhiteRider
Moderator
 
Posts: 54025
Joined: Sat Jan 19, 2008 7:06 pm
Location: UK

Re: Custom Stats Formatting

Postby degoor » Tue Nov 08, 2011 5:41 am

I have edited the above expression to the following:

format( '{1}% ({2}/{3})', if(cnt_float_turn_opp=0, "NA", format_number((cnt_float_turn / cnt_float_turn_opp) * 100,0,false,false)), format_number(cnt_float_turn,0,false,false), format_number(cnt_float_turn_opp,0,false,false) )

As for the formatting of the results it works fine.

@WhiteRider
Posted the above before reading your comment, WhiteRider.

I am going to try it and hope it works. Thanks!
degoor
 
Posts: 18
Joined: Wed Sep 30, 2009 2:22 am

Re: Custom Stats Formatting

Postby WhiteRider » Tue Nov 08, 2011 5:56 am

That will work fine, but means that you will always have the times/opportunities displayed wherever you use the stat - if that's what you want that's fine (I have a few stats like that myself).
WhiteRider
Moderator
 
Posts: 54025
Joined: Sat Jan 19, 2008 7:06 pm
Location: UK

Re: Custom Stats Formatting

Postby degoor » Thu Nov 10, 2011 4:55 am

If I use the long format ("format" function, ect) the stat doesn't change in relation to the player's position.

If I use the short format (your suggestion, WhiteRider) it doesn't show the times/opportunities - all I get is just "()"

I guess I will have to use both formatting creating twin stats that differ only in their formatting.
degoor
 
Posts: 18
Joined: Wed Sep 30, 2009 2:22 am

Re: Custom Stats Formatting

Postby WhiteRider » Thu Nov 10, 2011 5:33 am

Have you got the Value Expression in the exact structure I mentioned above?
If you don't have that right then the Times/Opportunities property will not work. If you export your stat and attach it to a Support ticket we'll be able to help you get it working as you like.
WhiteRider
Moderator
 
Posts: 54025
Joined: Sat Jan 19, 2008 7:06 pm
Location: UK

Re: Custom Stats Formatting

Postby degoor » Thu Nov 10, 2011 7:49 am

Yes, exactly as in your post.

It is strange but when there are 2 spaces before/after "*"and "/", the stat's formatting is different from the formatting of the stat with a single space.
degoor
 
Posts: 18
Joined: Wed Sep 30, 2009 2:22 am

Re: Custom Stats Formatting

Postby kraada » Thu Nov 10, 2011 10:24 am

Yes the formatting section is very sensitive to any changes. Are you certain when you were using /%.2f that you turned the show times/opportunities property to be on for that statistic? The default is to have it off.
kraada
Moderator
 
Posts: 54430
Joined: Wed Mar 05, 2008 2:32 am
Location: NY


Return to Custom Stats, Reports, and SQL [Read Only]

Who is online

Users browsing this forum: No registered users and 7 guests