最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

qlikview - Qlik - Need help creating a calculated field that contains a sum of some of the values in another column - Stack Over

programmeradmin0浏览0评论

I have a data set that looks like this:

Column A Column B Column C
Q1 1743 382
Q1 1376
Q2 1599 419
Q2 1283

I have a data set that looks like this:

Column A Column B Column C
Q1 1743 382
Q1 1376
Q2 1599 419
Q2 1283

And my goal is to create a calculated field that takes the number in Column C and divides it by the sum of the numbers in Column B that fall within the same date range. For example, the calculation for Q1 would be 382 / (1743 + 1376)

Thanks in advance!

Best, Abraham

P.S. - I tried to use the SUM and IF functions, but I received an error message that told me that SUM is an invalid function.

Share Improve this question edited Feb 5 at 20:23 Abraham Maalouf asked Feb 5 at 20:21 Abraham MaaloufAbraham Maalouf 12 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Not sure what you want to do with the calculated field once its calculated but the example below will create the calculated field in separate table and link to the main data table on the Column A field:

RawData:
Load * Inline [
Column A, Column B, Column C
Q1      , 1743    , 382
Q1      , 1376    ,
Q2      , 1599    , 419
Q2      , 1283
];

CalculatedData:
Load
  [Column A],
  sum([Column C]) / sum([Column B]) as CalcField
Resident
  RawData
Group By
  [Column A]
;

Once the script is reloaded the data model will be as the image below and the CalcField will have values below:

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论