比较两个字段的集合分析

Set Analysis comparing two fields

我使用余额日期和兑换率有效时的 MatchInterval 将期末余额列表链接到一组货币汇率。我在两个字段中都有多种货币,所以想 return 当两种货币匹配并应用正确的汇率时。

sum( {$ <BalanceAutoNumber={"=BalanceCurrency=Currency"}>} ClosingBalance*CADMultiply) 

根据在线指南,我已将字段 BalanceAutoNumber 添加到余额 table 作为我要 select 的维度。但是,只有在两个字段中手动 select 时,我才会得到结果。

我可以使用如下 IF 语句实现此目的

sum(if(CompanyCurrency=Currency,ClosingBalance*CADMultiply,0))

作为临时解决方案,我修改了我的数据模型,以便数据之间的间隔匹配链接强制这种关系。

CurrencyIntervalMatchRaw:
IntervalMatch(DateForCurrencyRates)
Load distinct StartDateTime, EndDateTime
Resident CurrencyRates;

join(CurrencyIntervalMatchRaw)
Load Distinct Currency
Resident CurrencyRates;


CurrencyIntervalMatch:
Load date(DateForCurrencyRates,'YYYYMMDD')&'_'&Currency as %Join_CurrencyRates,
    Currency,
    StartDateTime,
    EndDateTime
Resident CurrencyIntervalMatchRaw;

Drop Table CurrencyIntervalMatchRaw;
Drop Field DateForCurrencyRates From Balances;

有了这个修改后的模型,我不需要设置分析来限制显示的数据。