Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
ThisIsIt
Frequent Visitor

Insertar decimal

¡Buenos días! Tengo una columna de números enteros, y me gustaría insertar un decimal después del segundo dígito. ¿Cómo haría esto? Ejemplo a continuación. Actualmente el número es: 12345678 Me gustaría que el número sea: 12.345678 También algo que el número es 0. Si 0 sólo quiero que se quede 0 (si es posible). ¡Gracias!
1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@ThisIsIt - Tal vez:

DAX Column = IF([Column] = 0,0,[Column]/1000000)

Power Query Column = if [Column] = 0 then 0 else [Column]/1000000

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

5 REPLIES 5
FrankAT
Community Champion
Community Champion

Hola @ThisIsIt

si la longitud del número entero difiere, puede hacerlo con Power Query de la siguiente manera:

// Table
let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQyNjE1M7dQio0FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Value = _t]),
    #"Added Custom" = Table.AddColumn(Source, "Custom", each Text.Start([Value],2) & "." & Text.End([Value],Text.Length([Value])-2)),
    #"Changed Type" = Table.TransformColumnTypes(#"Added Custom",{{"Custom", type number}})
in
    #"Changed Type"

o puedes hacerlo con DAX:

25-08-_2020_13-27-33.png

Decimal Number = 
CONVERT (
    LEFT ( CONVERT ( 'Table (2)'[Value], STRING ), 2 ) & "."
        & RIGHT (
            CONVERT ( 'Table (2)'[Value], STRING ),
            LEN ( CONVERT ( 'Table (2)'[Value], STRING ) ) - 2
        ),
    DOUBLE
)

Una versión más corta de la fórmula DAX anterior es:

Decimal Number = 
CONVERT (
    LEFT ( 'Table (2)'[Value], 2 ) & "."
        & RIGHT (
            'Table (2)'[Value],
            LEN ('Table (2)'[Value] ) - 2
        ),
    DOUBLE
)

Saludos FrankAT

Gracias a todos por sus respuestas rápidas y sugerencias. Todos trabajan para mí. ¡Realmente lo aprecias!

Anonymous
Not applicable

Haría la siguiente columna calculada.

Decimal column =
VAR __p1 =
    LEFT ( 'Table'[Column], 2 )
VAR __p2 =
    RIGHT ( 'Table'[Column], LEN ( 'Table'[Column] ) - 2 )
RETURN
    __p1 & "." & __p2

Anote editar el nombre de la tabla y el nombre de columna para que se adapten.

Greg_Deckler
Super User
Super User

@ThisIsIt - Tal vez:

DAX Column = IF([Column] = 0,0,[Column]/1000000)

Power Query Column = if [Column] = 0 then 0 else [Column]/1000000

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
amitchandak
Super User
Super User

@ThisIsIt ,

crear un número como [columna]/1000000 , cambiar el tipo de datos a decimal con 6 decimales

12345678/1000000

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.