在具有多个表的Power BI中计算日期差异

时间:2019-02-04 16:04:55

标签: powerbi

我正在尝试计算Power Bi中2个日期之间的差。我需要联接3个单独的表才能获取正确的数据。这是我的Dax(测量)代码

Average Decision Time = CALCULATE(
DATEDIFF(Enquiries_venues[RecordCreated],EnquiryStatusVersion[RecordCreated], DAY),
FILTER ( Enquiries, Enquiries[TestEnquiry] = 0 && (Enquiries[EnquiryStatusId] = 45 || Enquiries[EnquiryStatusId] = 50 || Enquiries[EnquiryStatusId] = 55 || Enquiries[EnquiryStatusId] = 56 || Enquiries[EnquiryStatusId] = 60)),
FILTER ( Enquiries_Venues, Enquiries_Venues[EnquiryVenueProposalId] = 60),
FILTER ( EnquiryStatusVersion, EnquiryStatusVersion[EnquiryStatusId] = 45)

但是,date-diff部分目前无法识别表。当我将此部分放在底部时,它也不起作用,因为calculate函数要求表达式优先。

这是错误消息 enter image description here

任何帮助将不胜感激。

2 个答案:

答案 0 :(得分:0)

您正在将表列传递到"http://domain_two.com"中,而不是期望的标量日期中。

尝试将这些列包装在<!DOCTYPE html> <html> <head> </head> <body> b <script> const decoder = new TextDecoder(); let data; window.addEventListener("message", receiveMessage, false); function receiveMessage(event) { // check `origin` of `event` if (event.origin !== opener.location.origin) return; console.log(event); // process `formData` from `popup` data = JSON.parse(decoder.decode(event.data)); // do stuff with `formData` p.textContent = JSON.stringify(data, null, 2); } // wait for `load` event to be dispatched before posting message to `opener` onload = () => { opener.postMessage("ok", opener.location.href); } </script> <pre id="p"></pre> </body> </html> 之类的聚合函数中,以获取单个日期值。

答案 1 :(得分:0)

您可以尝试以下措施吗?

Average Decision Time = CALCULATE(
AVERAGE(DATEDIFF(Enquiries_venues[RecordCreated],EnquiryStatusVersion[RecordCreated], DAY)),
FILTER ( Enquiries, Enquiries[TestEnquiry] = 0 && (Enquiries[EnquiryStatusId] = 45 || Enquiries[EnquiryStatusId] = 50 || Enquiries[EnquiryStatusId] = 55 || Enquiries[EnquiryStatusId] = 56 || Enquiries[EnquiryStatusId] = 60)),
FILTER ( Enquiries_Venues, Enquiries_Venues[EnquiryVenueProposalId] = 60),
FILTER ( EnquiryStatusVersion, EnquiryStatusVersion[EnquiryStatusId] = 45)