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

Join 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

Reply
gautampruthi
Helper II
Helper II

Custom Column Help (DAX/M Code)

Hi, 
I am trying to create a custom colulmn based on the criteria given below

If {crs_code} like ["PMF*","PMP*","PMY*"] then "PGCE Core" 
else If {crs_code} like ["PDF*","PDP*","PDY*"] then "PGCE SD Salaried"  
else If {crs_code} like ["PTF*","PTP*","PTY*"] then "PGCE SD Train" 
else If ({crs_code} like ["Q?F3*","Q?P3*","Q?F4*F","Q?P4*F","Q?Y*","T?P*","T?F*"] and {srs_sce.sce_blok} <> "0") then "UG ITE" 
else If {crs_code} like "T?S*" then "Top-Up" 
else If {crs_code} like "PS*" then "SCITT" 
else If ({crs_code} like ["B?J4*F","B?S4*F"] or ({crs_code} like ["Q?F4*F","Q?P4*F","B?P4PRFY*F"] and {sce_blok} = "0")) then "First degree with Fnd Yr" 
else If {crs_code} like ["B?S2*","B?J3*","B?S3*","B?J4*P","B?S4*P","B?S5*","B?S6*"] then "First degree" 
else If {crs_code} like "AO*" then "Assessment Only" 
else If {crs_code} like ["MAS*","MSS*","MBA*","MRS*","MCS*","MDS*"] then "Postgraduate" 
else If {crs_code} like "AK*" then "SKE" 
else If {crs_code} like "CC*" then "Other UG" 
else If {crs_code} like "F?S*" then "Foundation degree" If {crs_code} like "R*" then "MPhil/PhD" 
else If {crs_code} like "AXS*" then "Exchange"

else If {crs_code} like ["R*","M*"] then "Postgraduate" else "Other Undergraduate"

here "?" wildcard donate any one digit or character and "*" donated zero or more digit/character

2 REPLIES 2
gautampruthi
Helper II
Helper II

Hi @rajendraongole1 how can i replicate this as this is bit tricky
 If ({crs_code} like ["Q?F3*","Q?P3*","Q?F4*F","Q?P4*F","Q?Y*","T?P*","T?F*"] and {srs_sce.sce_blok} <> "0") then "UG ITE" 

i tried using Text.Middle

rajendraongole1
Super User
Super User

Hi @gautampruthi In Power query editor, add a Custom Column

Add Column tab  >> Custom Column.
You can use the Text.StartsWith function to check the prefixes and the wildcard "?" will be handled with a combination of Text.StartsWith and Text.Contains

 

= Table.AddColumn(Source, "Custom Category", each
if Text.StartsWith([crs_code], "PMF") or Text.StartsWith([crs_code], "PMP") or Text.StartsWith([crs_code], "PMY") then "PGCE Core"
else if Text.StartsWith([crs_code], "PDF") or Text.StartsWith([crs_code], "PDP") or Text.StartsWith([crs_code], "PDY") then "PGCE SD Salaried"
else if Text.StartsWith([crs_code], "PTF") or Text.StartsWith([crs_code], "PTP") or Text.StartsWith([crs_code], "PTY") then "PGCE SD Train"

else if Text.StartsWith([crs_code], "R") or Text.StartsWith([crs_code], "M") then "Postgraduate"
else "Other Undergraduate"
)

 

and so on. add remaining condition with the similar approach.

 

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.