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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

undefined

Hey guys,
I need to create a column in my powerbi table (powerquery) with the following condition


If "brand" column is = "PEUGEOT" AND "CITROEN" then get the position from 1 to 3
ELSE
position from 4 to 6.

Thanks

 

1 ACCEPTED SOLUTION

Hi @Anonymous,

 

Do you mean something like:

Source = FatorequisicaoDetalhe

Or if the table/query name has spaces or special characters:

Source = #"FatoRequisicaoDetalhe"

Kind regards,

John

View solution in original post

8 REPLIES 8
Anonymous
Not applicable

tks John

Anonymous
Not applicable

 

Claro João, sem problemas. 
Coluna "Marca_Ajustada" e Coluna Chassi, A coluna que preciso, precisa pegar as 3 primeiras posições do chassis,
se a coluna "marca_ajustada" for equal a  Citroen ou Peugeot,
se for diferente, então tome as posições 4 a 6

edumach_0-1676635745752.png

 

Hola, 

 

if I understand your idea correctly, you can do it simiar to this:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wcs4sKcpPzVPSUTI0MjYxNYMwlGJ1opUCUkvTU/NLgCJgGXMIAyzlll+UAuSChS2ADBAJEg/Jr8wvSQQKgCUsgQwQGRsLAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Marca = _t, Chassi = _t, Expected = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Marca", type text}, {"Chassi", type text}, {"Expected", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if List.Contains({"CITROEN", "PEUGEOT"}, Text.Upper([ Marca])) then Text.Start([Chassi], 3) else Text.Range([Chassi], 3, 3), type text)
in
    #"Added Custom"

 

Cheers,

John

Anonymous
Not applicable

John, how would I point the source to my data table.

Data Table = "FatoRequisicaoDetalhe"
And in this structure that you gave as an example I create a new table, I need to include columns in the same table "FatoRequisicaoDetalhe"

Hi @Anonymous,

 

Do you mean something like:

Source = FatorequisicaoDetalhe

Or if the table/query name has spaces or special characters:

Source = #"FatoRequisicaoDetalhe"

Kind regards,

John

jbwtp
Memorable Member
Memorable Member

Hi @Anonymous,

 

This can be done through the AddColumn menu in PBI Power Query Editor.

This is not clear, however, what do you mean by "get the position from 1 to 3"?

 

Cheers,

John

Anonymous
Not applicable

I have a field called Chassis, in position 1 to 3 I can identify the Peugeot and Citroen models, in position 4 to 6 I have the other manufacturers, I could do this separately, but I would need to duplicate the field and apply this rule , the question is can I do this only once, with one condition?

Hi @Anonymous,

 

Do you mind visualising what you are saying with a couple of screenshots or tables, so it was clear where do you start and what are you trying to achieve?

 

Thanks,

John

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors