cancel
Showing results for 
Search instead for 
Did you mean: 
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
Ailsa-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
Power BI December 2021 Update_carousel 768x460.jpg

Check it Out!

Click here to read more about the December 2021 Updates!

Jan 2022 Dev Camp 768x460 copy.png

Power BI Dev Camp- January 27th, 2022

Mark your calendars and join us for our next Power BI Dev Camp!

UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!