Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
How can I add leading zeros in Power Query only if a certain criteria is met. For example, I have a column where the number of digits can range from 10-13, but all of them need to be 13 digits. So if the field contains 10 digits, I would need to add 3 leading zeros. If it contained 11 digits, I would need to add 2 leading zeros, etc.
Thanks!
Solved! Go to Solution.
@PowerBI123456 , then you reference a specific column in the formula
Table.AddColumn(#"Previous step", "Leading 0s", each Number.ToText([number column], Text.Repeat("0",13)))
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
If you need to keep them as number format, you can also use Custom Format Strings after you load the data.
Use custom format strings in Power BI Desktop - Power BI | Microsoft Docs
Regards,
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
Hi, @PowerBI123456 , you might want to follow this pattern to format all numbers,
Number.ToText(1234567890, Text.Repeat("0",13))
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
@PowerBI123456 , then you reference a specific column in the formula
Table.AddColumn(#"Previous step", "Leading 0s", each Number.ToText([number column], Text.Repeat("0",13)))
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
112 | |
97 | |
85 | |
67 | |
59 |
User | Count |
---|---|
150 | |
120 | |
100 | |
87 | |
68 |