空变量 QlikView

huangapple go评论88阅读模式
英文:

empty variables qlik view

问题

为什么我的变量是空的?

date(date#([dateto], 'YYYYMMDD'), 'YYYY-MM-DD') as [datetonew],
date(date#([datefrom], 'YYYYMMDD'), 'YYYY-MM-DD') as [datefromnew];
SQL
SELECT
*
FROM [BI_DWH_CORE].[Reporting].[v_QV_COM_SalesFunnel_DateParams];

let va = date(date#([dateto],'YYYY-MM-DD'), 'DDMMYYYY');
let vb = date(date#([datefrom],'YYYY-MM-DD'), 'DDMMYYYY');
let vblob = 'My name is blob!';

let vblob 是正常的。那只是个测试。日期变量里面是空的。

附言:在 Qlik 中这些字段确实会返回值。感谢。

英文:

Why are my variables empty?

[SalesFunnel_DateParams_temp]:  
Load
  date(date#([dateto], 'YYYYMMDD'), 'YYYY-MM-DD') as [datetonew],
  date(date#([datefrom], 'YYYYMMDD'), 'YYYY-MM-DD') as [datefromnew];
SQL 
SELECT  
  *
FROM [BI_DWH_CORE].[Reporting].[v_QV_COM_SalesFunnel_DateParams];

let va = date(date#([dateto],'YYYY-MM-DD'), 'DDMMYYYY');
let vb = date(date#([datefrom],'YYYY-MM-DD'), 'DDMMYYYY');
let vblob = 'My name is blob!';

let vblob is fine. that was a test. The date variables contain nothing.

PS. the fields do return values in Qlik.

Many thanks.

答案1

得分: 2

你无法像那样获取字段值。一个字段可以包含多个值。在这种情况下,您将不得不循环遍历字段值或获取特定位置的字段值。

单个(特定)位置的值

如果您想从特定位置的字段中获取值,那么您可以使用 peek 函数。

let vA = peek('datetonew');
let vB = peek('datetonew', 1);

在上面的示例中,vA 将返回 datetonew 字段的最后加载的值(peek 缺少一个可选的位置参数)。

对于 vB,我们明确说明我们想要从 datetonew 字段获取第一个值。

循环遍历所有值

如果您仍然想要循环遍历字段中的所有值,那么您可以使用 For each ... next 语句。

For Each i in FieldValueList('datetonew')
	trace $(i);
next

上面的脚本将仅打印 datetonew 字段中的每个不同值。

英文:

You cant get field values like that. A field can contain more than one value. In this case you'll have to loop through the field values or get field value on specific position.

Single (specific) value on position

If you want to get value from a field in specific position then you can use peek function.

let vA = peek('datetonew');
let vB = peek('datetonew', 1);

In the above example vA will return the last loaded value from datetonew field (peek is missing an optional position parameter).

For vB we explicitly stating that we want the 1st value from datetonew field.

Loop through all values

If you still want to loop through all values in a field then you can use For each ... next statement.

For Each i in FieldValueList('datetonew')
	trace $(i);
next

The script above will just print each DISTINCT value from datetonew field.

huangapple
  • 本文由 发表于 2023年4月20日 00:46:03
  • 转载请务必保留本文链接:https://go.coder-hub.com/76056990.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定