简体   繁体   English

在 Power BI 中对 2 个表使用 3 个日期字段

[英]Using 3 date fields over 2 tables in Power BI

I am new to Power BI and need to display a visual showing data requests, deadlines and returns.我是 Power BI 的新手,需要显示一个显示数据请求、截止日期和返回的视觉对象。 I have the idea of a line and clustered bar chart - the line to show the amount of notices given to a business from the date a data notice is given to the deadline date.我有一个折线和聚集条形图的想法 - 这条线显示从数据通知发出之日到截止日期期间向企业发出的通知数量。 The bars can then show the amount of data received.然后,这些条可以显示接收到的数据量。

I have two table in Power BI.我在 Power BI 中有两个表。 Notices and Historical Data . NoticesHistorical Data
Notices contains the fields - Business Name , Amount of Notices , Request Date and Deadline . Notices包含字段 - Business NameAmount of NoticesRequest DateDeadline
Historical Data contains the fields - Business Name , Amount Returned and Return Date . Historical Data包含字段 - Business Name 、退货Amount ReturnedReturn Date

I have the tables in a relationship using Business Name in a many-to-many join.我在多对多联接中使用Business Name的关系中的表。 I have tried several attempts to create charts however struggling with the fact there are 3 date fields.我已经尝试了几次创建图表的尝试,但是因为有 3 个日期字段这一事实而苦苦挣扎。 I cannot get them to show in one chart together.我无法让它们一起显示在一张图表中。 I attempted to create a table with the appended date fields from each table and then create relationships between the new date table and the original tables however this cannot be done with the original tables having an active relationship as well.我尝试使用每个表中的附加日期字段创建一个表,然后在新日期表和原始表之间创建关系,但是对于具有活动关系的原始表也无法做到这一点。 The visual also needs to be able to filter using slicers etc so all relationships need to be active.视觉对象还需要能够使用切片器等进行过滤,因此所有关系都需要处于活动状态。

Any help would be greatly appreciated.任何帮助将不胜感激。 Even another visual if recommended as I am new to Power BI.如果我是 Power BI 的新手,甚至推荐使用另一个视觉效果。 It's worth noting I would like to create a Gantt chart but do not have the add-on.值得注意的是,我想创建一个甘特图,但没有附加组件。
Thanks.谢谢。

Additional info:附加信息:
Tables are below.表格如下。 The business name can appear many times in each table as the requests are annually and they will have several data return records for each notice request.企业名称可以在每个表中出现多次,因为请求是每年一次,并且每个通知请求都会有多个数据返回记录。

Historical Data
在此处输入图像描述

Notices 在此处输入图像描述

From your question I think the issue you have is that with the calendar table you can only have one active relationship on a table, so for example you should have something like this.根据您的问题,我认为您遇到的问题是,对于日历表,您只能在表上拥有一个活动关系,因此例如您应该有这样的东西。 (I have also added a Business Name table to remove cross filtering between the to tables). (我还添加了一个企业名称表以删除 to 表之间的交叉过滤)。

I've used this example data:我使用了这个示例数据:

在此处输入图像描述

And offset the deadline by 6 days并将截止日期提前 6 天

在此处输入图像描述

So by using the calendar table you can map to date the values for the 'Amount Returned' via the Return Data & 'Amount of Notices' by the Deadline date, but can't see values for the 'Request Date', and doesn't show them correctly.因此,通过使用日历表,您可以 map 在截止日期之前通过返回数据和“通知金额”确定“返回金额”的值,但看不到“请求日期”的值,并且没有t 正确显示它们。

在此处输入图像描述

So if 16th Jan is selected you'll get:因此,如果选择 1 月 16 日,您将获得:

在此处输入图像描述

When it should just be a value of 15 for 'Total by Deadline'当“截止日期总计”的值应仅为 15 时

What you have to do is create two measures one that uses the active and one that will use the inactive relationship via USERELATIONSHIP So for example:您需要做的是创建两个度量,一个使用活动的,一个将通过USERELATIONSHIP使用非活动的关系例如:

    Total by Deadline = SUM(Notices[Amount of Notices])
    Total by Request = CALCULATE(SUM(Notices[Amount of Notices])
                      , USERELATIONSHIP('Calendar'[Date], Notices[Request Date]))

The USERELATIONSHIP forces the measure to use the inactive relationships, and should allow you to filter via selected dates correctly. USERELATIONSHIP 强制度量使用非活动关系,并且应该允许您正确过滤所选日期。

在此处输入图像描述

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM