Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hi @tamerj1 @amitchandak @SpartaBI, @Jihwan_Kim
Could you please help me in achieving this either in DAX or PowerQuery.
One of my column in table has values like this.
I wanted to create another column in same table by adding "0" in the begining for the values which dose not contain "-" and other value which contains "-" should remains same as it is.
For example column 'C_SerialNumber' have values like "311211025073516" and "916429-19-11"
I wanted to add '0' in the begining if the value DOES NOT Contain '-'. So the output will be "0311211025073516" and other values remains same.
Thanks
RK
Solved! Go to Solution.
Dear @raghukumarch ,
I have implemented your scenario, Here's the few steps to achieve the required output.
Go to Home - > Transform Data
Open the Query which contains the column C_SerialNumber.
Go to - > Add Column - > Custom Column
New Column Name: CheckColumn
Custom column formula: Text.Contains([C_SerialNumber],"-")
Now click on OK.
Now again click on Add Column - > Custom Column
New Column Name: NewC_SerialNumber
Custom column formula: if [CheckColumn] = false then "0" & [C_SerialNumber] else [C_SerialNumber]
Now click on OK.
Now, check on the formula bar, if the type isn't set to text then write it in a way as below screen short and click on the tick.
Here's the desire output in a new column.
Please like the reply and accept it as a solution to help the Power BI Community.
Dear @raghukumarch ,
I have implemented your scenario, Here's the few steps to achieve the required output.
Go to Home - > Transform Data
Open the Query which contains the column C_SerialNumber.
Go to - > Add Column - > Custom Column
New Column Name: CheckColumn
Custom column formula: Text.Contains([C_SerialNumber],"-")
Now click on OK.
Now again click on Add Column - > Custom Column
New Column Name: NewC_SerialNumber
Custom column formula: if [CheckColumn] = false then "0" & [C_SerialNumber] else [C_SerialNumber]
Now click on OK.
Now, check on the formula bar, if the type isn't set to text then write it in a way as below screen short and click on the tick.
Here's the desire output in a new column.
Please like the reply and accept it as a solution to help the Power BI Community.
Hi @Greg_Deckler Thanks for the quick response. Please find the attachment for sample data. and expected results. I couldn't find an option to attach sample data in xlsx. hence sharing a screenshot here.
@raghukumarch DAX Help for Custom/Conditional Column - Microsoft Power BI Community
Please don't cross-post. Sorry, having trouble following, can you post sample data as text and expected output?
Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882
Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490
The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
5 | |
2 | |
1 | |
1 | |
1 |
User | Count |
---|---|
10 | |
4 | |
3 | |
2 | |
2 |