如何计算多值列中的值计数并在条形图中可视化?

How to calculate the value count in multi-value columns and visualize in bar chart?

我有以下 csv 文件,其中 C_DS 和 C_RT 中的值可以是多值。

dataCenter,C_TID,C_DS,C_RT
dcA,test_403,"performance","performanceOverallRating"
dcB,test_581,"performance","performanceOverallRating"
dcC,test_382,"performance,liveProfile","performanceOverallRating,potentialOverallRating,sysOverallPerformance,sysOverallPotential"
dcD,test_241,"performance","performanceOverallRating"
dcE,test_100,"performance","performanceOverallRating,potentialOverallRating"
dcF,test_243,"performance","performanceOverallRating"
dcH,test_282,"performance,liveProfile","performanceOverallRating,potentialOverallRating,sysOverallPerformance"
dcH,test_281,"compensation,talentFlag","finalRangePenetration,riskOfLoss"
dcK,test_1000,"compensation,performance","finalRangePenetration,objectiveOverallRating"
......

现在我想计算 C_DS 和 C_RT 列中的值计数,然后在两个条形图中将其可视化。

预期数据转换输出为:

C_DS,count
performance,3
liveProfile,5
compensation,2
talentFlag,1
....


C_RT, count
performanceOverallRating,5
potentialOverallRating,7
finalRangePenetration,2
......

如何实现这个要求?

你可以这样试试。首先,将列中的唯一标签列表计算为新 table.

'SampleData'

C_DS_label = 

VAR SplitByCharacter = ","
VAR Table0 =
    SELECTCOLUMNS(
    ADDCOLUMNS (
        GENERATE (
            ROW ( "Text", CONCATENATEX(SampleData,SampleData[C_DS],",") ),
            VAR TokenCount =
                PATHLENGTH ( SUBSTITUTE ( [Text], SplitByCharacter, "|" ) )
            RETURN
                GENERATESERIES ( 1, TokenCount )
        ),
        "Word", PATHITEM ( SUBSTITUTE ( [Text], SplitByCharacter, "|" ), [Value] )
    ),
    "Word",[Word])
RETURN
    SUMMARIZE(Table0,[Word])

创建度量:

Count_C_DS = 
var curr = SELECTEDVALUE(C_DS_label[Word])
return
calculate(COUNTROWS('SampleData'), FILTER(ALL('SampleData'[C_DS]), PATHCONTAINS(SUBSTITUTE ( SampleData[C_DS], ",", "|" )  , curr) ))