Forum Discussion
Multiple responses from forms combining
- 4 years ago
Hi zaraanderson ,
In this case you need to take a different approach, keeping the responses has you have you can create disconnected tables with the answrs from the multioption. In this case I have created 2 tables:
Now using this I have created the following two measures:
Pet Count = // Character that split phrase into words VAR SplitByCharacter = ";" // Temporary table that splits selected phrase into words VAR Words_table = ADDCOLUMNS ( GENERATE ( SELECTCOLUMNS ( SUMMARIZE ( ALLSELECTED ( 'Sheet1 (2)' ), 'Sheet1 (2)'[Respondent ID], 'Sheet1 (2)'[Pet type (select all that apply)] ), "Find_Text", 'Sheet1 (2)'[Pet type (select all that apply)] ), VAR TokenCount = PATHLENGTH ( SUBSTITUTE ( [Find_Text], SplitByCharacter, "|" ) ) RETURN GENERATESERIES ( 1, TokenCount ) ), "Word", PATHITEM ( SUBSTITUTE ( [Find_Text], SplitByCharacter, "|" ), [Value] ) ) RETURN COUNTROWS ( FILTER ( Words_table, [Word] IN VALUES ( Pets[Pet type] ) ) ) Food Count = // Character that split phrase into words VAR SplitByCharacter = ";" // Temporary table that splits selected phrase into words VAR Words_table = ADDCOLUMNS ( GENERATE ( SELECTCOLUMNS ( SUMMARIZE ( ALLSELECTED ( 'Sheet1 (2)' ), 'Sheet1 (2)'[Respondent ID], 'Sheet1 (2)'[Favourite foods (select all that apply)] ), "Find_Text", 'Sheet1 (2)'[Favourite foods (select all that apply)] ), VAR TokenCount = PATHLENGTH ( SUBSTITUTE ( [Find_Text], SplitByCharacter, "|" ) ) RETURN GENERATESERIES ( 1, TokenCount ) ), "Word", PATHITEM ( SUBSTITUTE ( [Find_Text], SplitByCharacter, "|" ), [Value] ) ) RETURN COUNTROWS ( FILTER ( Words_table, [Word] IN VALUES ( Foods[Favourite foods] ) ) )Has you can see now you can use these two measures on your calculation:
PBIX attach.
Hi zaraanderson ,
In this case you need to take a different approach, keeping the responses has you have you can create disconnected tables with the answrs from the multioption. In this case I have created 2 tables:
Now using this I have created the following two measures:
Pet Count =
// Character that split phrase into words
VAR SplitByCharacter = ";" // Temporary table that splits selected phrase into words
VAR Words_table =
ADDCOLUMNS (
GENERATE (
SELECTCOLUMNS (
SUMMARIZE (
ALLSELECTED ( 'Sheet1 (2)' ),
'Sheet1 (2)'[Respondent ID],
'Sheet1 (2)'[Pet type (select all that apply)]
),
"Find_Text", 'Sheet1 (2)'[Pet type (select all that apply)]
),
VAR TokenCount =
PATHLENGTH ( SUBSTITUTE ( [Find_Text], SplitByCharacter, "|" ) )
RETURN
GENERATESERIES ( 1, TokenCount )
),
"Word", PATHITEM ( SUBSTITUTE ( [Find_Text], SplitByCharacter, "|" ), [Value] )
)
RETURN
COUNTROWS ( FILTER ( Words_table, [Word] IN VALUES ( Pets[Pet type] ) ) )
Food Count =
// Character that split phrase into words
VAR SplitByCharacter = ";" // Temporary table that splits selected phrase into words
VAR Words_table =
ADDCOLUMNS (
GENERATE (
SELECTCOLUMNS (
SUMMARIZE (
ALLSELECTED ( 'Sheet1 (2)' ),
'Sheet1 (2)'[Respondent ID],
'Sheet1 (2)'[Favourite foods (select all that apply)]
),
"Find_Text", 'Sheet1 (2)'[Favourite foods (select all that apply)]
),
VAR TokenCount =
PATHLENGTH ( SUBSTITUTE ( [Find_Text], SplitByCharacter, "|" ) )
RETURN
GENERATESERIES ( 1, TokenCount )
),
"Word", PATHITEM ( SUBSTITUTE ( [Find_Text], SplitByCharacter, "|" ), [Value] )
)
RETURN
COUNTROWS ( FILTER ( Words_table, [Word] IN VALUES ( Foods[Favourite foods] ) ) )
Has you can see now you can use these two measures on your calculation:
PBIX attach.
Hi MFelix,
Wow I think this works. Now I have to figure out how to apply it to my actual dataset. Hopefully I can slog through that, and then let you know when I am successful. Hopefully I won't have anymore questions, but my knowledge isn't great so hopefully I can deduce without any trouble.
Thanks,
Zara