• Resolved zensoft

    (@zensoft)


    Hello, I wanted to know how I can change the date format in the summary table.

    How can I sum the values associated with a very specific year.
    Example:
    My Table is

    Date Value
    08-02-2015 1
    02-01-2015 8
    01-01-1999 2
    14-06-2014 6
    06-02-2014 2

    Sum 2015 is 9; Sum 1999 is 2; Sum 2014 is 8;

    it is important that they are done the sums of the individual years.
    I hope it is clear what I need.
    Thank you

    https://www.ads-software.com/plugins/contact-form-7-to-database-extension/

Viewing 15 replies - 1 through 15 (of 15 total)
  • Plugin Author Michael Simpson

    (@msimpson)

    Add something like this to your short code:
    trans="Date=date(Y,submit_time)&&SumField(Value,Date)"

    See this example: https://cfdbplugin.com/?page_id=1167

    Thread Starter zensoft

    (@zensoft)

    Hello Michael, unfortunately, the code that I have spent not working.

    I, however, I used
    trans code = "SumField (credits, date)"

    I have divided the data into three fields, so I take the reference Year alone, for example:

    The contact form is

    day:5 month:Feb year:2015 credit:5
    day:7 month:Feb year:2014 credit:7
    day:10 month:Feb year:2015 credit:10

    I write this code
    [cfdb-table form="example" trans="SumField(Crediti,year)"]

    this is the results:

    2015 15
    2014 7

    I finally managed to do what I needed, without using the date field, if I have done something wrong let me know.

    Thank you and have a nice day

    Thread Starter zensoft

    (@zensoft)

    I have another similar question.

    This code:
    `[cfdb-table form=”example” trans=”SumField(Crediti,Anno)”]

    It returns the table divided by years with the sum of credits.

    Now need, that sum is made considering the years, but only to a specific person.

    For Example:
    I have this table
    name|year|credit
    mario|2000|2
    tiziana|2001|10
    mario|2000|9
    mario|1999|1

    if I am logged in as Mario, this is the table that I see:
    name|year|credit
    mario|2000|11
    mario|1999|1

    while if you are logged in as Tiziana, this is the table that I see:
    name|year|credit
    tiziana|2001|10

    I hope it is clear what I need.
    Thank you

    Plugin Author Michael Simpson

    (@msimpson)

    try:

    trans="SumField(Crediti,name,Anno)"

    Thread Starter zensoft

    (@zensoft)

    Micheal I tried the code you suggested and this is the table result:

    nome|credits|
    mario|12
    tiziana|10

    I need this table, when Mario is logged in, he sees:
    nome|anno|credits
    mario|2000|11
    mario|1999|1

    instead, when Tiziana is logged in, she sees:
    nome|anno|credits
    tiziana|2001|10

    It’s a okay even if the user name is not written.

    Thank you

    Plugin Author Michael Simpson

    (@msimpson)

    My mistake. It only support 1 “group by” field. But you can approximate it by combining the two field into one then doing the sum. Like this:

    trans="new_field=concat(nome,' ', anno)&&SumField(credits,new_field)"

    Thread Starter zensoft

    (@zensoft)

    Hi Michael, I write your code:
    `trans=”Prova=Concat(Nome,’ ‘, Anno)&&SumField(Crediti,Prova)

    It works but the table does not have to be displayed in full, but must be displayed only one that belongs the user logged

    For example if I am logged as Tiziana, I’m read the table with only credits made by me, I can not even read the credits made by other user.

    Thank you

    Plugin Author Michael Simpson

    (@msimpson)

    Thread Starter zensoft

    (@zensoft)

    I had already tried this code:

    `filter=”Submitted Login=$user_login”

    but the table comes out empty, even if they are logged in, for example, as tiziana.

    Thank You

    ps.
    this is all code:
    [cfdb-table form="Modulo" filter="Submitted Login=$user_login" trans="Prova=Concat(Nome,' ', Anno)&&SumField(Crediti,Prova)"]

    Thread Starter zensoft

    (@zensoft)

    There is no news for me?

    Plugin Author Michael Simpson

    (@msimpson)

    That should work assuming that you have entries with Submitted Login filled in for the currently logged in user. If the user is not logged in at the time he submits a form, then his login information is not captured.

    Thread Starter zensoft

    (@zensoft)

    Micheal I deleted the table all the data, I logged on and rewritten data, the table is still empty.

    This code is correct:

    [cfdb-table form="Modulo di contatto 1" filter="Submitted Login=$user_login" trans="Prova=Concat(Nome,' ', Anno)&&SumField(Crediti,Prova)"]

    thank you

    Thread Starter zensoft

    (@zensoft)

    I tried the code
    `filter=”Submitted Login=$user_login”

    in this string:
    [cfdb-value function="sum" form="Modulo di contatto 1" show="Crediti" filter="Submitted Login=$user_login"]

    It’s works very well, it may be that filter is not compatible with trans ?

    Plugin Author Michael Simpson

    (@msimpson)

    “trans” happens before “filter” … change “filter” to “tfilter” to make it happen before.

    Thread Starter zensoft

    (@zensoft)

    Thanks a lot Michael, you were very kind and professional.
    Thanks and thanks again.

    the code I used is this:

    [cfdb-table form="Modulo di contatto 1" trans="Anni=Concat(' ', Anno)&&SumField(Crediti,Anni)" tfilter="Submitted Login=$user_login"]

    so the public can be useful to someone else.

    Thanks a lot.

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘As you change the date format in the table, and as they sum the values of date’ is closed to new replies.