新手在这里。我正在尝试根据Power BI中的两个条件设置一个名为“Label”的返回值。我们公司有23个国家。如果他们遇到3个特定国家,那么我希望标签在下面标注为“汽车”,如果他们不符合这些国家,那么我基本上想根据我的第2层名称标准给它一个备用标签。
问题是,这些经理中的一些人在这3个国家中也有人数,可能是照片或相机,但他们希望他们说汽车。
不幸的是,这对我不起作用。任何帮助将不胜感激。
这是我想要做的DAX:
Label =
VAR _Country = SWITCH(
TRUE (),
ActiveHC[Country Name] = "Turkey", "Cars",
ActiveHC[Country Name] = "Greece", "Cars",
ActiveHC[Country Name] = "Italy", "Cars",
Blank()
)
VAR _Segment = SWITCH(
True(),
ActiveHC[Layer 2] = "Beth", "Corporate",
ActiveHC[Layer 2] = "Joanie", "Corporate",
ActiveHC[Layer 2] = "Dan", "Corporate",
ActiveHC[Layer 2] = "Bill", "Corporate",
ActiveHC[Layer 2] = "Christina", "Corporate",
ActiveHC[Layer 2] = "Steven", "Cars",
ActiveHC[Layer 2] = "Bobby", "Audio",
ActiveHC[Layer 2] = "Matt", "Photos",
ActiveHC[Layer 2] = "Peter", "Photos",
ActiveHC[Layer 2] = "Edward", "Photos",
ActiveHC[Layer 2] = "Joey", "Software",
ActiveHC[Business Unit] = "Cameras", "Cameras",
BLANK ()
)
RETURN IF(ISBLANK(_Country), _Segment, _Country)
我本质上希望能够创建一个表格:
Label Count
Cars 7
Imaging 1
Audio 1
Corporate 1
Software 1
Photos 1
我还想将该字段用作过滤器,并将此计算列添加到表中,其他数据作为记录导出。
任何帮助将非常感激。非常感谢!!!
![数据样本] https://imgur.com/a/Q5ZTgR9
在模型中创建计算列,如下所示:
Country Name Filtered =
SWITCH (
TRUE (),
ActiveHC[Country Name] = "Turkey", "Cars",
ActiveHC[Country Name] = "Greece", "Cars",
ActiveHC[Country Name] = "Italy", "Cars",
BLANK ()
)
然后,创建另一个名为segment的计算列:
Segment =
SWITCH (
TRUE (),
ActiveHC[Layer 2] = "Beth", "Corporate",
ActiveHC[Layer 2] = "Joanie", "Corporate",
ActiveHC[Layer 2] = "Dan", "Corporate",
ActiveHC[Layer 2] = "Bill", "Corporate",
ActiveHC[Layer 2] = "Christina", "Corporate",
ActiveHC[Layer 2] = "Steven", "Cars",
ActiveHC[Layer 2] = "Bobby", "Audio",
ActiveHC[Layer 2] = "Matt", "Photos",
ActiveHC[Layer 2] = "Peter", "Photos",
ActiveHC[Layer 2] = "Edward", "Photos",
ActiveHC[Layer 2] = "Joey", "Software",
ActiveHC[Business Unit] = "Cameras", "Cameras",
BLANK ()
)
将这些列合并到另一个列中,称之为混合或其他:
Blended =
IF ( ISBLANK ( Table[Country Name Filtered] ), Table[Segment], Table[Country Name Filtered] )
现在,您可以在切片器或测量中更轻松地引用这些值:
Count Values :=
COUNT ( Table[Blended] )
因此,您基本上可以使用Table [Blended]作为行值和[Count Values]作为度量来创建表格或矩阵。
不是一个优雅的解决方案,但它会工作。
希望能帮助到你!!!