Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Haydn_R
Helper I
Helper I

help with text search with a deliminter

I tring to achieve the below, look for a value within a string and count the ID if the condition is met.

The 1st table is a summarised view of the data and the 2nd table is the desired outcome.

 

I've tried the below, but it is returning 106 for "Other", when it should be 131.

 

Program External Count = 
SWITCH(
    TRUE(),   
    CONTAINSSTRING('External Requets'[Program],"Other"),'External Requets'[COUNT],

    BLANK()
)

 

 

Data set: External Requets
Text Field: Program

Numerical Field : ID (a count of this not sum) 

or

COUNT : CALCULATE(COUNTA('External Requets'[ID]),NOT( ISBLANK('External Requets'[ID]))) 

 

 

Summarised data

 

ProgramCount
All LBM29
All LBM;#Other4
CCC Support11
CCC Support;#MMMcare;#All LBM3
CCC Support;#MMMcare;#All LBM;#Other2
CCC Support;#MMMcare;#Other1
DDD, SSSS and CCC3
DDD, SSSS and CCC;#EEEEE Services1
EEEG Information Line23
EEEG Information Line;#All LBM1
EEEEE Services7
FFF and Mummmm10
FFF and Mummmm;#Other1
FFF and Mummmm;#YYY and STUUU;#EEEEE Services1
MMMcare80
MMMcare;#All LBM;#Other1
MMMcare;#Other7
MMMcare;#PGTU Integrity;#All LBM1
OOO ZZZs15
OOO ZZZs;#DDD, SSSS and CCC;#Other1
OOO ZZZs;#FFF and Mummmm;#DDD, SSSS and CCC;#YYY and STUUU;#EEEEE Services10
OOO ZZZs;#FFF and Mummmm;#DDD, SSSS and CCC;#YYY and STUUU;#Other1
OOO ZZZs;#Other4
Other106
PGTU Integrity4
YYY and STUUU2
YYY and STUUU;#EEEEE Services2
OOO ZZZs;#DDD, SSSS and CCC;#EEEEE Services2
OOO ZZZs;#FFF and Mummmm;#DDD, SSSS and CCC;#YYY and STUUU;#EEEEE Services;#Other1
CCC Support;#MMMcare;#OOO ZZZs;#FFF and Mummmm;#DDD, SSSS and CCC;#YYY and STUUU;#EEEEE Services;#Other1
YYY and STUUU;#EEEEE Services;#Other1
FFF and Mummmm;#EEEEE Services1
FFF and Mummmm;#YYY and STUUU1
PGTU Integrity;#All LBM1
OOO ZZZs;#YYY and STUUU1

 

Desired result

 

ProgramID
CCC Support18
MMMcare96
PGTU Integrity6
OOO ZZZs36
FFF and Mummmm27
DDD, SSSS and CCC20
YYY and STUUU21
EEEEE Services27
All LBM42
Other131
EEEG Information Line24
3 ACCEPTED SOLUTIONS
Ashish_Mathur
Super User
Super User

Hi,

In the Query Editor, split the contents into rows using ; as the delimiter.  Write this measure

Measure = sum(Data[Count])

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

amitchandak
Super User
Super User

@Haydn_R , You can try the suggestion from @Ashish_Mathur , If that does not workout, Please check this

 

Power BI- Text Part slicer to filter/search text - https://youtu.be/MKKWeOqFG4c
https://medium.com/@amitchandak/power-bi-search-text-parts-in-text-ad2f9783ffa2

View solution in original post

v-yifanw-msft
Community Support
Community Support

Hi @Haydn_R ,
The helpful suggestions from @Ashish_Mathur  and @amitchandak can provide you with many ideas. I have created an example for you to solve the problem.
1. Separate Program with ;# in Power Query

vyifanwmsft_1-1707198314718.png

 

2.Unpivot Column from Program.1 to Program.8

vyifanwmsft_2-1707199435783.png

 

Advanced Editor:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("tVNdT8IwFP0rzfq6h22oaPqEmyMmNDMZe9gIDwtWXQIbqcXEf29XpaOlpRLCfeu5536ck97Fwpus12D2iD3fix68pS8BBDP2QSjHbwQcxzHId9ttRxnHwlAHEcQYr2pKEBxajtysYU50grzn/I5NksQHOQ9Qt6+AV8hRRxkEn/oAOaFfzYp8yh4cnILn9q2jm5o1XQtmTUv6LUb29KE02UVtPhZwmqZiAbzb8OjZgQHXZenZsizFO58XRWEV8ucRf98Hh4DB4VDN7+GxCr9M5wWXzsg7bdj3seYsy0BVVWKDWwVB0OC/Onyg6moNpU4Dgot72rZTP79kBXfirVokaUpv+aNdKiK3h86aS83UjbBc4dXmnUXWh1sO4+Q5SdZ/f7uxfvkD", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Program = _t, Count = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Program", type text}, {"Count", Int64.Type}}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Changed Type", "Program", Splitter.SplitTextByDelimiter(";#", QuoteStyle.Csv), {"Program.1", "Program.2", "Program.3", "Program.4", "Program.5", "Program.6", "Program.7", "Program.8"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Program.1", type text}, {"Program.2", type text}, {"Program.3", type text}, {"Program.4", type text}, {"Program.5", type text}, {"Program.6", type text}, {"Program.7", type text}, {"Program.8", type text}}),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type1", {"Count"}, "Attribute", "Value"),
    #"Removed Columns" = Table.RemoveColumns(#"Unpivoted Columns",{"Attribute"}),
    #"Reordered Columns" = Table.ReorderColumns(#"Removed Columns",{"Value", "Count"}),
    #"Renamed Columns" = Table.RenameColumns(#"Reordered Columns",{{"Value", "Program"}})
in
    #"Renamed Columns"

 

Fianl output:

vyifanwmsft_4-1707199818940.png

How to Get Your Question Answered Quickly - Microsoft Fabric Community

If it does not help, please provide more details with your desired out put and pbix file without privacy information.

 

Best Regards,

Ada Wang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

3 REPLIES 3
v-yifanw-msft
Community Support
Community Support

Hi @Haydn_R ,
The helpful suggestions from @Ashish_Mathur  and @amitchandak can provide you with many ideas. I have created an example for you to solve the problem.
1. Separate Program with ;# in Power Query

vyifanwmsft_1-1707198314718.png

 

2.Unpivot Column from Program.1 to Program.8

vyifanwmsft_2-1707199435783.png

 

Advanced Editor:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("tVNdT8IwFP0rzfq6h22oaPqEmyMmNDMZe9gIDwtWXQIbqcXEf29XpaOlpRLCfeu5536ck97Fwpus12D2iD3fix68pS8BBDP2QSjHbwQcxzHId9ttRxnHwlAHEcQYr2pKEBxajtysYU50grzn/I5NksQHOQ9Qt6+AV8hRRxkEn/oAOaFfzYp8yh4cnILn9q2jm5o1XQtmTUv6LUb29KE02UVtPhZwmqZiAbzb8OjZgQHXZenZsizFO58XRWEV8ucRf98Hh4DB4VDN7+GxCr9M5wWXzsg7bdj3seYsy0BVVWKDWwVB0OC/Onyg6moNpU4Dgot72rZTP79kBXfirVokaUpv+aNdKiK3h86aS83UjbBc4dXmnUXWh1sO4+Q5SdZ/f7uxfvkD", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Program = _t, Count = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Program", type text}, {"Count", Int64.Type}}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Changed Type", "Program", Splitter.SplitTextByDelimiter(";#", QuoteStyle.Csv), {"Program.1", "Program.2", "Program.3", "Program.4", "Program.5", "Program.6", "Program.7", "Program.8"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Program.1", type text}, {"Program.2", type text}, {"Program.3", type text}, {"Program.4", type text}, {"Program.5", type text}, {"Program.6", type text}, {"Program.7", type text}, {"Program.8", type text}}),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type1", {"Count"}, "Attribute", "Value"),
    #"Removed Columns" = Table.RemoveColumns(#"Unpivoted Columns",{"Attribute"}),
    #"Reordered Columns" = Table.ReorderColumns(#"Removed Columns",{"Value", "Count"}),
    #"Renamed Columns" = Table.RenameColumns(#"Reordered Columns",{{"Value", "Program"}})
in
    #"Renamed Columns"

 

Fianl output:

vyifanwmsft_4-1707199818940.png

How to Get Your Question Answered Quickly - Microsoft Fabric Community

If it does not help, please provide more details with your desired out put and pbix file without privacy information.

 

Best Regards,

Ada Wang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

amitchandak
Super User
Super User

@Haydn_R , You can try the suggestion from @Ashish_Mathur , If that does not workout, Please check this

 

Power BI- Text Part slicer to filter/search text - https://youtu.be/MKKWeOqFG4c
https://medium.com/@amitchandak/power-bi-search-text-parts-in-text-ad2f9783ffa2

Ashish_Mathur
Super User
Super User

Hi,

In the Query Editor, split the contents into rows using ; as the delimiter.  Write this measure

Measure = sum(Data[Count])

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.