Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowThe Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.
Hi,
I need to replicate this code in Power BI, How can i achive this.
"?" refers to any single character and "*" refers to zero or more characters
If {srs_crs.crs_code} like ["PMF*","PMP*","PDF*","PDP*","PTF*","PTP*"] then "Primary PGCE" else "" +
If {srs_crs.crs_code} like ["Q?F*","Q?P*","T?F*","T?P*"] then "Primary ITE" else "" +
If {srs_crs.crs_code} like ["PMY*","PDY*","PTY*"] then "Secondary PGCE" else "" +
If {srs_crs.crs_code} like "Q?Y*" then "Secondary ITE" else "" +
If {srs_crs.crs_code} like ["B?P4*","BAJ*","BAS*","BLS*","BSJ*","BSS*","T?S*"] then "First Degree" else "" +
If {srs_crs.crs_code} like "F*" then "Foundation Degree" else "" +
If {srs_crs.crs_code} like "AO*" then "Assessment Only" else "" +
If {srs_crs.crs_code} like "AK*" then "SKE" else "" +
If {srs_crs.crs_code} like "PS*" then "SCITT" else "" +
If {srs_crs.crs_code} like "ANP*" then "EYITT" else "" +
If {srs_crs.crs_code} like "AXS*" then "Exchange" else "" +
If {srs_crs.crs_code} like ["R*","M*"] then "Postgraduate" else "Other Undergraduate"
Solved! Go to Solution.
Use this in power query as a custom column and use the following custom M code.
if Text.StartsWith([crs_code], "PMF") or Text.StartsWith([crs_code], "PMP") or Text.StartsWith([crs_code], "PDF") or Text.StartsWith([crs_code], "PDP") or Text.StartsWith([crs_code], "PTF") or Text.StartsWith([crs_code], "PTP") then "Primary PGCE"
else if (Text.StartsWith([crs_code], "Q") and Text.Middle([crs_code], 1, 1) in {"F","P"}) or (Text.StartsWith([crs_code], "T") and Text.Middle([crs_code], 1, 1) in {"F","P"}) then "Primary ITE"
else if Text.StartsWith([crs_code], "PMY") or Text.StartsWith([crs_code], "PDY") or Text.StartsWith([crs_code], "PTY") then "Secondary PGCE"
else if Text.StartsWith([crs_code], "Q") and Text.Middle([crs_code], 1, 1) = "Y" then "Secondary ITE"
else if Text.StartsWith([crs_code], "B") and Text.Middle([crs_code], 1, 1) in {"P4","AJ","AS","LS","SJ","SS"} or (Text.StartsWith([crs_code], "T") and Text.Middle([crs_code], 1, 1) = "S") then "First Degree"
else if Text.StartsWith([crs_code], "F") then "Foundation Degree"
else if Text.StartsWith([crs_code], "AO") then "Assessment Only"
else if Text.StartsWith([crs_code], "AK") then "SKE"
else if Text.StartsWith([crs_code], "PS") then "SCITT"
else if Text.StartsWith([crs_code], "ANP") then "EYITT"
else if Text.StartsWith([crs_code], "AXS") then "Exchange"
else if Text.StartsWith([crs_code], "R") or Text.StartsWith([crs_code], "M") then "Postgraduate"
else "Other Undergraduate"
Try this and let me know if this works.
Use this in power query as a custom column and use the following custom M code.
if Text.StartsWith([crs_code], "PMF") or Text.StartsWith([crs_code], "PMP") or Text.StartsWith([crs_code], "PDF") or Text.StartsWith([crs_code], "PDP") or Text.StartsWith([crs_code], "PTF") or Text.StartsWith([crs_code], "PTP") then "Primary PGCE"
else if (Text.StartsWith([crs_code], "Q") and Text.Middle([crs_code], 1, 1) in {"F","P"}) or (Text.StartsWith([crs_code], "T") and Text.Middle([crs_code], 1, 1) in {"F","P"}) then "Primary ITE"
else if Text.StartsWith([crs_code], "PMY") or Text.StartsWith([crs_code], "PDY") or Text.StartsWith([crs_code], "PTY") then "Secondary PGCE"
else if Text.StartsWith([crs_code], "Q") and Text.Middle([crs_code], 1, 1) = "Y" then "Secondary ITE"
else if Text.StartsWith([crs_code], "B") and Text.Middle([crs_code], 1, 1) in {"P4","AJ","AS","LS","SJ","SS"} or (Text.StartsWith([crs_code], "T") and Text.Middle([crs_code], 1, 1) = "S") then "First Degree"
else if Text.StartsWith([crs_code], "F") then "Foundation Degree"
else if Text.StartsWith([crs_code], "AO") then "Assessment Only"
else if Text.StartsWith([crs_code], "AK") then "SKE"
else if Text.StartsWith([crs_code], "PS") then "SCITT"
else if Text.StartsWith([crs_code], "ANP") then "EYITT"
else if Text.StartsWith([crs_code], "AXS") then "Exchange"
else if Text.StartsWith([crs_code], "R") or Text.StartsWith([crs_code], "M") then "Postgraduate"
else "Other Undergraduate"
Try this and let me know if this works.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the February 2025 Power BI update to learn about new features.
User | Count |
---|---|
86 | |
78 | |
54 | |
39 | |
35 |
User | Count |
---|---|
102 | |
84 | |
48 | |
48 | |
48 |