基于多个切片器值显示用户数Power BI
我正在处理观看人数表
,该表可告知客户观看资产的数量。有两个资产过滤器。一个供观看,另一个供不观看。根据资产过滤器,我需要显示观看节目的客户数量;没看节目的顾客。以下是我使用的方法。
I am working on a Viewership table
which tells numbers of customers watches asset. There are two asset filters. One for watched and one for not Watched. Based on the asset filters, I need to display number of customers who watched the show & customers who didn't watched the show. Below is the method I have used.
首先,创建一个新表 Asset:
First, created a new table "Asset":
此表包含唯一资产,并用于创建影响DAX度量但不影响外观(表)的切片器。资产表与查看者表断开连接(无关系)。
This table contains unique assets and used it to create a slicers that affects DAX measure but does not affect the visual (table). Asset table disconnected from the Viewership table (no relationships).
为未被监视的资产创建了上表的副本,并将其命名为asset_1
Created the copy of the above table for not watched assets and named it as asset_1
以下是收视率表。
创建以下度量以获取查看选定资产的客户(从第一个分片器中查看)&未查看所选资产(来自第二个切片器)的客户&
Created below measures to get the customers who viewed the selected asset (from first slicer) & he customers who not viewed the selected asset (from second slicer) &
Watched Status =
VAR Selected_Assets = ALLSELECTED(Asset[asset_id])
VAR Customer_Assets = VALUES(Viewership[asset_id])
VAR Assets_Watched = COUNTROWS(INTERSECT(Customer_Assets, Selected_Assets))
RETURN
IF(Assets_Watched > 0, "Watched", "Not Watched")
Not Watched Status =
VAR Selected_Assets = ALLSELECTED(Asset_1[asset_id])
VAR Customer_Assets = VALUES(Viewership[asset_id])
VAR Assets_Watched = COUNTROWS(INTERSECT(Customer_Assets, Selected_Assets))
RETURN
IF(Assets_Watched > 0, "Watched", "Not Watched")
我低于结果
之后,我可以看到所需的结果。
after applying below filters in the visual filter pane I can see the desired result.
已监视状态=已监视,
未监视状态=未监视
Watched Status= "Watched", Not Watched Status = "Not Watched"
现在,我有一个要求,可以显示具有上述过滤条件的客户总数(而非客户列表)。例如:在上述情况下,客户数为1。
Now I got a Requirement to show total number of customers (Instead list of customers) with above filter criteria. For e.g: In the above case customer count is 1.
我尝试过以下测量。
Customer Count = CALCULATE(DISTINCTCOUNT(Viewership[customer_id]),FILTER(Viewership,([Watched Status]= "Watched") &&left([Not Watched Status],3)="Not"))
预期结果为1(客户ID:4)。但是我得到的结果是2。有人可以帮忙在这里找出问题吗?
The expected result is 1 (Customer ID: 4). But I am getting result as 2. Could someone help to identify the issue here?
您可以做的就是拖拽customer_id在视觉效果列中,并确保将其设置为不重复计数。
What you can do is drag teh customer_id in the visual as column and ensure it is set to count distinct.
选择您的视觉效果,转到值下的可见化面板,您可以看到该列,单击向下箭头,弹出窗口将显示:
Select your visual, go the the vusialization panel under values you can see the column, click on arrowdown, popus will show: