March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hello! I am new to PowerBI.
I need to have a calculated column how to get the number of characters from a certain column(JobType_txt). However, there is one condition. Some of the Jobtype_txt dont have a value in # of _ Column. See screenshot below.
Condition is: If # of _ is " " then Phase_=" " else need a calculation for below requirement.
Example: Jobtype_txt: NC 110_Estimates__10NotStarted
The text is divided into
Prefix: NC 110
"_"
Phase_:Estimates_
"_",
Status:10NtotStarted
So, I need to have a calculated column the number of characters from Prefix until "Phase_". So from JobType_text: NC 110_Estimates_.
So the Phase_=17
I have this sample Excel formula for this. See screenshot below.
My problem is I don't know how to convert this to DAX formula.
I hope you can help me on this.
Thank you.
Solved! Go to Solution.
It seems that you created it as a calculated column, you need to create it as a measure intstead of a calculated column. if you want to create calculated column, you can refer to the following code.
Column = var a=SUBSTITUTE('Table'[_JobType_txt],"_","|")
return IF(NOT(ISBLANK('Table'[#of_])),LEN(PATHITEM(a,1))+LEN(PATHITEM(a,2))+2,0)
Then when you put the field to visual, you need to select 'Don't summarize'
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
You can refer to the following measure
Sample data
Measure:
Count_txt =
VAR a =
SUBSTITUTE ( SELECTEDVALUE ( 'Table'[_JobType_txt] ), "_", "|" )
RETURN
IF (
NOT ( ISBLANK ( MAX ( 'Table'[#of_] ) ) ),
LEN ( PATHITEM ( a, 1 ) ) + LEN ( PATHITEM ( a, 2 ) ) + 2,
0
)
Output
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Here is the entered formula but when I added the field in the visual it has Sum of Phase_
Did I did something wrong?
It seems that you created it as a calculated column, you need to create it as a measure intstead of a calculated column. if you want to create calculated column, you can refer to the following code.
Column = var a=SUBSTITUTE('Table'[_JobType_txt],"_","|")
return IF(NOT(ISBLANK('Table'[#of_])),LEN(PATHITEM(a,1))+LEN(PATHITEM(a,2))+2,0)
Then when you put the field to visual, you need to select 'Don't summarize'
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
pls try this
Count TEXT =
VAR LenText = LEN(MAX('Table'[_JobType_txt]))
VAR LenPatch = LEN(PATHITEMREVERSE( SUBSTITUTE(MAX('Table'[_JobType_txt]),"_","|"),1))
RETURN
IF( MAX('Table'[#of_]),
LenText - LenPatch ,0)
Share some data to work with (in a format the can be pasted in an MS Excel file) and show the expected result.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
134 | |
91 | |
89 | |
64 | |
58 |
User | Count |
---|---|
201 | |
137 | |
107 | |
72 | |
68 |