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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
rrjr007
Frequent Visitor

Creación de perfiles de clientes utilizando datos existentes

Me gustaría usar Power BI para crear perfiles de cliente basados en reglas. Hago esto es sobresalir y es un gran crucnh tiempo. Espero que esto sea lo que pueda hacer.

A continuación se muestran mis datos:

Empresa XManzanasMarca 11
Empresa XManzanasMarca 224794
Empresa XManzanasMarca 33472
Empresa XManzanasMarca 414
Empresa XManzanasMarca 5108
Empresa XManzanasMarca 653
Empresa XManzanasMarca 76907

Lo primero que hago es calcualte qué % de manzanas empresa x compras de varias marcas

Empresa XManzanasMarca 110.003%
Empresa XManzanasMarca 22479470.141%
Empresa XManzanasMarca 334729.822%
Empresa XManzanasMarca 4140.040%
Empresa XManzanasMarca 51080.306%
Empresa XManzanasMarca 6530.150%
Empresa XManzanasMarca 7690719.539%

A continuación, creo mis perfiles:

Abogado100%
Leales75% a 99%
Primaria40% a 74%
Secundaria11% a 39%
Terciario5% a 10%
Trialist1% a 4%
Ninguno0%

Mi salida debe parecerse a la tabla de abajo. ¿Puedo hacer esto en power bi? ¿Pensamientos sobre cómo?

Gracias de antemano.

EmpresaFruta• COMPRADOMarca 1Marca 2Marca 3Marca 4Marca 5Marca 6Marca 7
Empresa XManzanas35349NingunoPrimariaTerciarioNingunoNingunoNingunoSecundaria

1 REPLY 1
v-eachen-msft
Community Support
Community Support

Hola @rrjr007 ,

Aquí hay dos maneras.

1.Use DAX

Per = 
DIVIDE('Table'[# PURCHASED],CALCULATE(SUM('Table'[# PURCHASED]),ALLSELECTED('Table')))
Sum =
CALCULATE(SUM('Table'[# PURCHASED]), ALLSELECTED('Table'))

A continuación, puede utilizar la función IF() para mostrar los resultados finales.

2. Utilice la consulta m
Abra el editor de avances y consulte la siguiente consulta m:

let
    Source = Your source,
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}, {"Column2", type text}, {"Column3", type text}, {"Column4", Int64.Type}}),
    Custom1 = #"Changed Type",
    #"Renamed Columns" = Table.RenameColumns(Custom1,{{"Column1", "Company"}, {"Column2", "Fruit"},{"Column3", "Brand"},{"Column4", "# PURCHASED"}}),
    #"Grouped Rows" = Table.Group(#"Renamed Columns", {"Fruit"}, {{"Count", each List.Sum([#"# PURCHASED"]), type number}, {"sum", each _, type table [Company=text, Fruit=text, Brand=text, #"# PURCHASED"=number]}}),
    #"Expanded sum" = Table.ExpandTableColumn(#"Grouped Rows", "sum", {"Company", "Fruit", "Brand", "# PURCHASED"}, {"sum.Company", "sum.Fruit", "sum.Brand", "sum.# PURCHASED"}),
    #"Added Custom" = Table.AddColumn(#"Expanded sum", "Custom", each if
[#"sum.# PURCHASED"]/[Count] >=0.01 
and
[#"sum.# PURCHASED"]/[Count] <0.05
then
"Trialist"
else if 
[#"sum.# PURCHASED"]/[Count] >=0.05 
and
[#"sum.# PURCHASED"]/[Count] <0.11
then
"Tertiary"
else if 
[#"sum.# PURCHASED"]/[Count] >=0.11 
and
[#"sum.# PURCHASED"]/[Count] <0.4
then
"Secondary"
else if 
[#"sum.# PURCHASED"]/[Count] >=0.4 
and
[#"sum.# PURCHASED"]/[Count] <0.75
then
"Primary"
else if 
[#"sum.# PURCHASED"]/[Count] >=0.75 
and
[#"sum.# PURCHASED"]/[Count] <0.99
then
"Loyalist"
else if 
[#"sum.# PURCHASED"]/[Count] = 1
then
"Advocate"
else 
"None"),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"sum.# PURCHASED"}),
    #"Pivoted Column" = Table.Pivot(#"Removed Columns", List.Distinct(#"Removed Columns"[sum.Brand]), "sum.Brand", "Custom")
in
    #"Pivoted Column"

Aquí está el resultado.

3-1.PNG

Aquí está mi archivo de prueba para su referencia.

La tabla es creada por DAX, Table2 se crea por m consulta.

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.

Top Solution Authors
Top Kudoed Authors