Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
Assume we have the following column called [ERPCode] below. I want to dynamically return the second or third value within my serial key. If my ERP code contains "MI" return the second value, but if my ERP code contains "SI" then return me the third value in my serial key. A sample output is provided for reference.
Please help.
Thanks,
Mohan V.
Solved! Go to Solution.
Hi @Anonymous ,
You just modify the dax formula provided by @Fowmy .
Please try below dax formula:
Column =
VAR _code = [ERPCode]
VAR _len =
LEN ( _code )
VAR _a =
FIND ( ".", _code )
VAR _b =
IFERROR ( FIND ( ".", _code, _a + 1 ), 0 )
VAR _c =
IFERROR ( FIND ( ".", _code, _b + 1 ), 0 )
VAR _val =
SWITCH (
TRUE (),
CONTAINSSTRING ( _code, "MI" ),
IF ( _b <> 0, MID ( _code, _a + 1, _b - _a - 1 ), MID ( _code, _a + 1, _len ) ),
CONTAINSSTRING ( _code, "SI" ),
IF ( _c <> 0, MID ( _code, _b + 1, _c - _b - 1 ), MID ( _code, _b + 1, _len ) )
)
RETURN
_val
Please refer the attached .pbix file.
Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous ,
You just modify the dax formula provided by @Fowmy .
Please try below dax formula:
Column =
VAR _code = [ERPCode]
VAR _len =
LEN ( _code )
VAR _a =
FIND ( ".", _code )
VAR _b =
IFERROR ( FIND ( ".", _code, _a + 1 ), 0 )
VAR _c =
IFERROR ( FIND ( ".", _code, _b + 1 ), 0 )
VAR _val =
SWITCH (
TRUE (),
CONTAINSSTRING ( _code, "MI" ),
IF ( _b <> 0, MID ( _code, _a + 1, _b - _a - 1 ), MID ( _code, _a + 1, _len ) ),
CONTAINSSTRING ( _code, "SI" ),
IF ( _c <> 0, MID ( _code, _b + 1, _c - _b - 1 ), MID ( _code, _b + 1, _len ) )
)
RETURN
_val
Please refer the attached .pbix file.
Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@Anonymous
Will a Power Query solution work for you?
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
@Anonymous
Here is the DAX solution, add this as a Calculated Column:
Key =
IFERROR(
VAR __EPR = [ERP Code]
VAR P = LEFT( __EPR , 2 )
VAR P1 = FIND("." , __EPR)
VAR P2 = FIND("." , __EPR , P1 + 1 )
VAR P3 = FIND("." , __EPR , P2 + 1 )
VAR RESULT =
SWITCH(
P,
"MI", MID( __EPR, P1 + 1 , P2 - P1 - 1 ),
"SI", MID( __EPR, P2 + 1 , P3 - P2 - 1 )
)
RETURN
RESULT,
BLANK()
)
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
@Fowmy It is working but only issue here is if i dont have any delimeter then it is returing blank as in below case.
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
94 | |
87 | |
82 | |
71 | |
49 |
User | Count |
---|---|
143 | |
123 | |
107 | |
61 | |
55 |