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
EDS
Helper I
Helper I

COLUMNA

Buenos días, soy nuevo en Powerbi, y tengo una duda.

Dispongo de una tabla con dos columnas, una el codigo de cliente y otro el% de descuento y el concepto

La mayoria de los clientes tiene solo un% de descuento, pero hay casos en los que un cliente puede tener dos% de descuento, los cuales se aplican en cascada.

Por ejplo

cliente dcto concepto

1 5% de rappel

2 4% Pronto pago

3 2% Rappel

1 2% Pronto pago.

 

Como puede crear una tabla en la que aparezcan dos columnas, en la que por ejplo para el cliente 1 aparece una columna con el dcto del 5% y otra columna en la que aparece el 2%.

 

Gracias.

2 REPLIES 2
v-yetao1-msft
Community Support
Community Support

Hi @EDS 

The data you provided is not very clear, under what circumstances the customer’s discount percentage is 5% and when is 2% ? What is your formula for calculating this result ?

Could you provide us with some data, formulas or samples ?

 

Best Regards

Community Support Team _ Ailsa Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Fowmy
Super User
Super User

@EDS 

I used Power Query to create a solution. Paste the code given below on the Advanced Editor of a New Blank Query and check the steps.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTJVBRJBiQUFqTlKsTrRSkZArglILDg/P08hILEyNzWvBCxjDBQ0QlNtCBMLKMrPLSiBqdeDazBB1hALAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Cutomer = _t, Discount = _t, Concept = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Cutomer", Int64.Type}, {"Discount", Percentage.Type}, {"Concept", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Cutomer"}, {{"Count", each _, type table [Cutomer=nullable number, Discount=nullable number, Concept=nullable text]}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Discount 1", each [Count][Discount]),
    #"Extracted Values" = Table.TransformColumns(#"Added Custom", {"Discount 1", each Text.Combine(List.Transform(_, Text.From), "|"), type text}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Extracted Values", "Discount 1", Splitter.SplitTextByDelimiter("|", QuoteStyle.Csv), {"Discount 1.1", "Discount 1.2"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Discount 1.1", type number}, {"Discount 1.2", type number}}),
    #"Removed Columns" = Table.RemoveColumns(#"Changed Type1",{"Count"})
in
    #"Removed Columns"

Data:

Fowmy_1-1621669792353.png

 




Output:

Fowmy_0-1621669776389.png

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

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.

Top Solution Authors
Top Kudoed Authors