Welcome, Guest. Please login or register.
Did you miss your activation email?

Author Topic: Problem With SUM Function  (Read 4343 times)

merabi

  • Newbie
  • *
  • Posts: 29
    • View Profile
Problem With SUM Function
« on: November 24, 2018, 12:14:43 pm »
Hello.
i am having problem using sum function. when column name in my data source contains space sum function doesn't sum column values and gives syntax error.
my data source is QTableModel based.
this is the script in table footer cell:
Code: [Select]
$S{numberFormat($S{ SUM("$D{datasource.თვითღ ფასი}","DataBand1") }, "f", 2, "")}
please let me know how to fix this problem.
p.s. in the table rows values are shown properly. only sum function has problem.
this is the script in table data cell:
Code: [Select]
$S{numberFormat($D{datasource.თვითღ ფასი}, "f", 2, "")}

merabi

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: Problem With SUM Function
« Reply #1 on: November 24, 2018, 12:19:04 pm »
Added Image Showing The Problem

Arin Alex

  • Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 1005
    • View Profile
Re: Problem With SUM Function
« Reply #2 on: November 26, 2018, 10:04:51 pm »
Hi.
I've fixed the problem and pushed changes to github. Check it please.
« Last Edit: November 27, 2018, 07:28:01 pm by Arin Alex »

merabi

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: Problem With SUM Function
« Reply #3 on: November 29, 2018, 10:31:34 am »
Hi, our problem has resolved partially. In general your solution works except when column name contains dot.
For Example:
Code: [Select]
$S{numberFormat($S{SUM("$D{datasource.შესყ.ფასი}", "DataBand1")}, "f", 3, "")}doesn't work.

Arin Alex

  • Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 1005
    • View Profile
Re: Problem With SUM Function
« Reply #4 on: November 29, 2018, 11:02:41 pm »
Yet another attempt :) I've changed it and pushed. Check it please

merabi

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: Problem With SUM Function
« Reply #5 on: November 30, 2018, 12:59:20 pm »
Hi, this one is working, but when there is a space after dot script doesn't work.
For Example:
Code: [Select]
$S{numberFormat($S{SUM("$D{datasource.შესყ. ფასი}", "DataBand1")}, "f", 3, "")}Thank you for a quick response.

Arin Alex

  • Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 1005
    • View Profile
Re: Problem With SUM Function
« Reply #6 on: November 30, 2018, 04:55:50 pm »
Do you really need all this variants of field name? In fact it is not good practice to do a field name with spaces :)
« Last Edit: December 01, 2018, 12:19:13 am by Arin Alex »

Arin Alex

  • Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 1005
    • View Profile
Re: Problem With SUM Function
« Reply #7 on: December 01, 2018, 12:21:53 am »
I've made new changes. Check it please 

merabi

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: Problem With SUM Function
« Reply #8 on: December 01, 2018, 10:44:20 am »
Hi, now everything works as expected.
The reason we have such column names is that we are passing QTableModel as a data source.
Sometimes column names are large and contains multiple words. So they are shortened to achieve convenient look in a QTableView.
Thank you for your effort.