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
Anonymous
Not applicable

Calcular porcentaje y añadir al total

Hola

Estoy luchando para averiguar cómo lograr lo que quiero en PowerBI. Tengo una tabla de clientes (Table1), con una fila "Compartido".

Lo que quiero hacer es tomar el valor de 'Compartido' de Table1, y agregar el valor a cada fila de cliente, basado en la distribución de precentage en Table2. ¿Es posible algo así?

Por ejemplo, a continuación, el Cliente A se convertiría en '280' y el Cliente B se convertiría en '220'

Tabla1

Cliente A100
Cliente B200
Compartido300

Tabla2

Cliente A60%
Cliente B40%
1 ACCEPTED SOLUTION
az38
Community Champion
Community Champion

Hola @james2345

probar una columna como

Column = 
var _shared = MAXX(FILTER(Table1, Table1[Customer] = "Shared"), Table1[Value])
RETURN
RELATED(Table1[Value]) + Table2[Percent]*_shared

pero asegúrese de que tiene relaciones entre las tablas


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

View solution in original post

2 REPLIES 2
Mariusz
Community Champion
Community Champion

Hola @james2345

Consulte el archivo adjunto con una solución en Power Query o el siguiente script

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wci4tLsnPTS1ScFTSUTI0MFCK1UESdAIKGkEFgzMSi1JTgALGIIFYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Customer = _t, Value = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Customer", type text}, {"Value", Int64.Type}}),
    #"Merged Queries" = Table.NestedJoin(#"Changed Type", {"Customer"}, Table2, {"Shared"}, "Table2", JoinKind.LeftOuter),
    #"Expanded Table2" = Table.ExpandTableColumn(#"Merged Queries", "Table2", {"Customer", "Split"}, {"Table2.Customer", "Table2.Split"}),
    #"Replaced Value" = Table.ReplaceValue(#"Expanded Table2",null,1,Replacer.ReplaceValue,{"Table2.Split"}),
    #"Added Conditional Column" = Table.AddColumn(#"Replaced Value", "New Customer", each if [Table2.Customer] = null then [Customer] else [Table2.Customer], type text ),
    #"Added Custom" = Table.AddColumn(#"Added Conditional Column", "New Value", each [Value] * [Table2.Split], type number ),
    #"Grouped Rows" = Table.Group(#"Added Custom", {"New Customer"}, {{"New Value ", each List.Sum([New Value]), type number}})
in
    #"Grouped Rows"

Saludos
Mariusz

Si este post ayuda,entonces por favor considere aceptarlo como la solución.

Por favor, siéntase libre de conectarse conmigo.
Linkedin


az38
Community Champion
Community Champion

Hola @james2345

probar una columna como

Column = 
var _shared = MAXX(FILTER(Table1, Table1[Customer] = "Shared"), Table1[Value])
RETURN
RELATED(Table1[Value]) + Table2[Percent]*_shared

pero asegúrese de que tiene relaciones entre las tablas


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

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.