Forum Discussion
Leading Zero
- 10 years ago
If your source data has leading zeros, then you need to solve this when you import the data (assuming you are not connecting directly to the data source), by making sure you format the column as text in the query editor. Otherwise, you will need to create a calculated column that pads the store IDs with the correct number of leading zeros.
If your source data has leading zeros, then you need to solve this when you import the data (assuming you are not connecting directly to the data source), by making sure you format the column as text in the query editor. Otherwise, you will need to create a calculated column that pads the store IDs with the correct number of leading zeros.
- mlilkas10 years agoFrequent Visitor
Thanks Asocorro, I was able to pad the data. To add the leading numbers I used format(column,"000"). I did not have the "" before so it was not doing anything when I entered the zeros.
- mlilkas10 years agoFrequent Visitor
Hmm, I am trying to pad the numbers but FORMAT doesnt seem to be working, and I cant find a DAX formula that works either. Text.Pad doesnt seem to exist in Power BI
- Maryann7 years agoHelper I
I tried this solution but it gave me an error. I believe my problem is that the column I want to retain the leading zeroes on is the result of Max(column_name) . My table is grouped by booking_ID, getting max(column), and trying to use the result to merge booking_ID with max(seq) as a key to another table.
So my problem is without the leading zeroes, a one to one is turning into a many to many
12864 13
128641 3 are both coming out 1286413 creating many to many for the join.
When I do a format( max(seq), '000') I get an error.
Also changing the format to text doesn't add the leading zeroes.
thanks
- SJ7 years agoHelper I
Hi Maryann,
Tried a similar piece and have no issues but not sure what you are doing wrong.
The formula looks to be missing [] and the location it is pulling data from but not sure.
What you could try to make them unique is an "&" statement.
column 1 &" - "&max(Seq)
column 1 = column containing 12864 and 128641
This should work unless the error is in your: max(seq).
Hope this makes sense.
SJ
- Maryann7 years agoHelper I
Thanks SJ , This looks like a good fix .
- cuiping7 years agoFrequent Visitor
Otherwise, you will need to create a calculated column that pads the store IDs with the correct number of leading zeros.
How exactly can we performe above? thank you
- mucuracat2 years agoNew Member
I found the solution here:
https://radacad.com/add-leading-zeros-to-a-number-in-power-bi-using-power-query