我正在尝试使用Qlik集分析和范围求和来计算当月某个时间点处于活动状态的记录总数
例如,如果这些是记录:
id state created_date modified_date
1 expired 01/12/2014 10/12/2014
2 expired 01/12/2014 10/03/2015
3 active 01/12/2014 01/12/2014
4 expired 10/01/2015 12/01/2015
5 expired 10/01/2015 11/03/2015
6 active 10/02/2015 10/02/2015
7 expired 10/03/2015 11/03/2015
预期的o / p是
Dec-14 3
Jan-15 4
Feb-15 4
Mar-15 5
例如:2015年1月,结果应为4 - 2014年12月创建的1个活跃记录+ 12月1月+ 1创建的实际记录,实际于2015年3月到期
在记录过期时更新modified_date
所以我尝试了这个:
rangesum(above(Count({$<[state] = {'active'} >} id), 0,12))
+ Count({1<[state] ={'expired'}, modified_date.Calendar.Month ={">=$(created_date.Calendar.Month)"}>} id)
第二个计数语句是错误的。如何汇总当前未处于活动状态但在月中的某个时间点处于活动状态的记录。是否可以在不使用主日历的情况下实现此目的?
提前致谢!
答案 0 :(得分:0)
更好的方法是修改您的数据模型,使其包含如下所示的活动日期。
XMLLIST = {
//general settings
xml1: 'xml/structural_steel.xml?' + Math.random(0,1), //solve ie weird caching issue
xml2: 'xml/building_work_id.xml?' + Math.random(0,1), //solve ie weird caching issue
xml3: 'xml/shear_stud_welding.xml?' + Math.random(0,1), //solve ie weird caching issue
xml4: 'xml/custom_solution.xml?' + Math.random(0,1), //solve ie weird caching issue
appendTo: '#list', //set the id/class to insert XML data
init: function () {
//jQuery ajax call to retrieve the XML file
$.ajax({
type: "GET",
url: XMLLIST.xml1,
dataType: "xml",
success: XMLLIST.parseXML
});
$.ajax({
type: "GET",
url: XMLLIST.xml2,
dataType: "xml",
success: XMLLIST.parseXML
});
$.ajax({
type: "GET",
url: XMLLIST.xml3,
dataType: "xml",
success: XMLLIST.parseXML
});
$.ajax({
type: "GET",
url: XMLLIST.xml4,
dataType: "xml",
success: XMLLIST.parseXML
});
}, // end: init()
parseXML: function (xml) {
//Grab every single ITEM tags in the XML file
var data;
data = $('item', xml).get();
var i = 1;
//Loop through all the ITEMs
$(data).each(function () {
//Parse data and embed it with HTML
XMLLIST.insertHTML($(this));
i++;
});
}, // end: parseXML()
insertHTML: function (item) {
//retrieve each of the data field from ITEM
var url = item.find('url').text();
var image = item.find('image').text();
var title = item.find('title').text();
var html;
//Embed them into HTML code
html = '<div class="item">';
html += '<a href="' + url + '"><img src="' + image + '"></a><br>';
html += '<span class="contentsubtitle">' + title + '</span><br><br>';
html += '</div>';
//Append it to user predefined element
$(html).appendTo(XMLLIST.appendTo);
}, // end: insertHTML()
}
//Run this script
XMLLIST.init();
然后是活跃月份对ID进行独特计数的情况。看不到集合分析!