Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by watching the DP-600 session on-demand now through April 28th.
Learn moreJoin the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now
Hi guys,
I am trying to get location code from the column Subject in table FACT_Tasks - example below:
Logic: If Subject contains (anywhere) the specific text string (AAAA or BBBB), then
- If AAAA - then take 10 characters (including AAAA)
- If BBBB - then take 12 characters (including BBBB)
I would prefer to have this in DAX as calculated column and not via Power Query.
| Subject | Location code (calculated) |
| Texttexttext | (blank) |
| Task 1 - AAAA123456 | AAAA12345 |
| Task Subject Name - BBBB1234567-89 | BBBB12345-67 |
Thank you
IvanS
Solved! Go to Solution.
you can change the numbers 10 and 12 to any other numbers if it is necessary for you
How about if I want to do same but this time with Power Query not with DAX
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCkmtKCmBYqVYHaBAYnG2gqGCroIjEBgaGZuYmiHEg0uTslKTSxT8EnNTgUqcgACixFzXwlIpNhYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Subject = _t]),
Extracted = Table.AddColumn(Source, "Location code", each if Text.Contains([Subject], "AAAA") then Text.Range([Subject], Text.PositionOf([Subject], "AAAA"), 10) else try Text.Range([Subject], Text.PositionOf([Subject], "BBBB"), 12) otherwise null)
in
ExtractedExpertise = List.Accumulate( {Days as from Today}, {Skills and Knowledge}, (Current, Everyday) => Current & Day.LearnAndPractise(Everyday) ) |
you can change the numbers 10 and 12 to any other numbers if it is necessary for you
@Ahmedx How about if I want to do same but this time with Power Query not with DAX
Check out the April 2026 Power BI update to learn about new features.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
| User | Count |
|---|---|
| 40 | |
| 37 | |
| 32 | |
| 20 | |
| 15 |
| User | Count |
|---|---|
| 66 | |
| 58 | |
| 31 | |
| 25 | |
| 24 |