我对不同群体的成员(例如第1组至第4组)进行了调查,了解他们是否同意或不同意某些内容。我试图在Microsoft PowerBI Desktop中绘制这些响应。
我加载了一个数据模型,在单个表中包含这些列:
Group Question1 Question2
Group1 Agree Agree
Group1 Disagree Agree
Group4 Disagree Disagree
Group3 Agree Agree
Group2 Disagree Agree
Group2 Agree Disagree
Group4 Agree Agree
Group1 Agree Disagree
我想知道是否有一个可以计算单词出现次数的DAX"同意"和"不同意"这样我可以将它们作为堆积条形图上的值(每个问题一个图表):
Group1 Agree--------- Disagree----
Group2 Agree------- Disagree-------
Group3 Agree---------- Disagree----
Group4 Agree------ Disagree--------
(为ASCII艺术道歉)
我尝试过使用COUNTA()函数,但它只是保持返回行数。我还尝试将问题列作为数据字段拖动,但又一次,只是使每个条的长度相同,因为它们的总响应数相同。
提前致谢。
答案 0 :(得分:2)
您需要将您的桌子取消 - 以获得如下结构:
Group | Question | Answer
Group1 | Question1 | Agree
Group1 | Question2 | Disagree
...
您的措施如下所示:
RowCount:= COUNTROWS(FactAnswer)
AgreeCount:=
CALCULATE(
[RowCount]
,FactAnswer[Answer] = "Agree"
)
DisagreeCount:=
CALCULATE(
[RowCount]
,FactAnswer[Answer] = "Disagree"
)
答案 1 :(得分:0)
我们需要创建六个度量(清晰和简化)
1)Agree Q1 = CALCULATE(COUNTA(SO_table[Question1]),SO_table[Question1]="Agree")
2)Agree Q2 = CALCULATE(COUNTA(SO_table[Question2]),SO_table[Question1]="Agree")
3)Disagree Q1 = CALCULATE(COUNTA(SO_table[Question1]),SO_table[Question1]="Disagree")
4)Disagree Q2 = CALCULATE(COUNTA(SO_table[Question2]),SO_table[Question1]="Disagree")
5)Total Agree = Agree Q1 + Agree Q2
6)Total Disagree = Disagree Q1 + Disagree Q2
然后,您可以使用堆积条并绘制Total Agree
& Total Disagree
答案 2 :(得分:0)
您可以使用以下DAX表达式为每个问题创建一个表:
Table = SUMMARIZE('YourTable',YourTable[Group],"Agree",
COUNTAX(FILTER('YourTable',YourTable[Question1]="Agree"),
YuorTable[Question1]),"Disagree",
COUNTAX(FILTER('YourTable',YourTable[Question1]="Disagree"),YourTable[Question1]))
示例:
YourTable
对于Question1,您将获得下表:
获得表后,只需创建所需的图表。
如果这有用,请告诉我。