Power BI - importing conditional clauses

Paul0702

New Member
Joined
Jul 26, 2022
Messages
16
Office Version
  1. 2016
Platform
  1. Windows
Hello - I was wondering if it possible to import conditional clauses into an already existing Power BI table. we have multiple vendors and daily transactions that need cleaning up to make them look more uniform. like we do not need invoice numbers or posting dates from our systems when pulling the raw data into the power BI table. is there a way if I were to setup a separate spreadsheet with the formatting/clauses that I need for it to work? i already have some clauses in place but to manually do over 100 clauses would take forever. thank you for any help and advice. please let me know if more information is needed and I can hopefully help elaborate further.
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
You have Table.SelectColumns() function in Power Query.
You could have a query in PBI that contains a list with the columns needed. And in the Table.SelectColumns() step of the result query, you can refer to this list.
Assunign this data "sys_export"
Some dateValuesys posting dateClientInvoice NumberTax regimeProduct item
9/01/202550025/01/2025ACME20250126-00001AITM-CRD-5478
10/01/202574225/01/2025MYC°20250126-00002AITM-BKE-3651
11/01/202534925/01/2025ACE20250126-00003BITM-KNF-9999


Query with list of column names: col_to_select
Power Query:
[RANGE=rs:4|cs:7|v:table|w:Book1|cls:xl2bb-210|s:Sheet1|tw:492][XR][XD=ch:0|w:67|cls:h][/XD][XD=ch:0|w:48|cls:h][/XD][XD=ch:0|w:93|cls:h][/XD][XD=ch:0|w:48|cls:h][/XD][XD=ch:0|w:92|cls:h][/XD][XD=ch:0|w:68|cls:h][/XD][XD=ch:0|w:77|cls:h][/XD][/XR][XR][XD=h:l|fw:b|bc:156082|c:FFFFFF|ch:15|cls:bl bt bb]Some date[/XD][XD=h:l|fw:b|bc:156082|c:FFFFFF|cls:bt bb]Value[/XD][XD=h:l|fw:b|bc:156082|c:FFFFFF|cls:bt bb]sys posting date[/XD][XD=h:l|fw:b|bc:156082|c:FFFFFF|cls:bt bb]Client[/XD][XD=h:l|fw:b|bc:156082|c:FFFFFF|cls:bt bb]Invoice Number[/XD][XD=h:l|fw:b|bc:156082|c:FFFFFF|cls:bt bb]Tax regime[/XD][XD=h:l|fw:b|bc:156082|c:FFFFFF|cls:bt br bb]Product item[/XD][/XR][XR][XD=bc:C0E6F5|ch:15|cls:bl bt bb|tx:45666|nf:m/d/yyyy]9/01/2025[/XD][XD=bc:C0E6F5|cls:bt bb]500[/XD][XD=bc:C0E6F5|cls:bt bb|tx:45682|nf:m/d/yyyy]25/01/2025[/XD][XD=h:l|bc:C0E6F5|cls:bt bb]ACME[/XD][XD=bc:C0E6F5|cls:bt bb]20250126-00001[/XD][XD=h:l|bc:C0E6F5|cls:bt bb]A[/XD][XD=h:l|bc:C0E6F5|cls:bt br bb]ITM-CRD-5478[/XD][/XR][XR][XD=ch:15|cls:bl bt bb|tx:45667|nf:m/d/yyyy]10/01/2025[/XD][XD=cls:bt bb]742[/XD][XD=cls:bt bb|tx:45682|nf:m/d/yyyy]25/01/2025[/XD][XD=h:l|cls:bt bb]MYC°[/XD][XD=cls:bt bb]20250126-00002[/XD][XD=h:l|cls:bt bb]A[/XD][XD=h:l|cls:bt br bb]ITM-BKE-3651[/XD][/XR][XR][XD=bc:C0E6F5|ch:15|cls:bl bt bb|tx:45668|nf:m/d/yyyy]11/01/2025[/XD][XD=bc:C0E6F5|cls:bt bb]349[/XD][XD=bc:C0E6F5|cls:bt bb|tx:45682|nf:m/d/yyyy]25/01/2025[/XD][XD=h:l|bc:C0E6F5|cls:bt bb]ACE[/XD][XD=bc:C0E6F5|cls:bt bb]20250126-00003[/XD][XD=h:l|bc:C0E6F5|cls:bt bb]B[/XD][XD=h:l|bc:C0E6F5|cls:bt br bb]ITM-KNF-9999[/XD][/XR][/RANGE]

Queyr with applied selection referring to that list.
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="sys_export"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Some date", type datetime}, {"Value", Int64.Type}, {"sys posting date", type datetime}, {"Client", type text}, {"Invoice Number", type text}, {"Tax regime", type text}, {"Product item", type text}}),
    Custom1 = Table.SelectColumns(#"Changed Type", col_to_select)
in
    Custom1

If with formatting , you mean data types, the you can create a list of lists. Where the inner list contains 2 items, the column name and the data type.

Power Query:
//cols_to_select
let
    Source = {
                 {"Some date", Date.Type}
                ,{"Value", Number.Type}
                //,"sys posting date"
                ,{"Client", Text.Type}
                //,"Invoice Number"
                ,{"Tax regime", Text.Type}
                ,{"Product item", Text.Type}
            }
in
    Source

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="sys_export"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,col_to_select),
    Custom1 = Table.SelectColumns(#"Changed Type", List.Transform(col_to_select, each List.First(_)))
in
    Custom1

You can extend the inner lists, so you can have the original name of import, the source or supplier, the to be name and the type.
 
Upvote 0
You have Table.SelectColumns() function in Power Query.
You could have a query in PBI that contains a list with the columns needed. And in the Table.SelectColumns() step of the result query, you can refer to this list.
Assunign this data "sys_export"
Some dateValuesys posting dateClientInvoice NumberTax regimeProduct item
9/01/202550025/01/2025ACME20250126-00001AITM-CRD-5478
10/01/202574225/01/2025MYC°20250126-00002AITM-BKE-3651
11/01/202534925/01/2025ACE20250126-00003BITM-KNF-9999


Query with list of column names: col_to_select
Power Query:
[RANGE=rs:4|cs:7|v:table|w:Book1|cls:xl2bb-210|s:Sheet1|tw:492][XR][XD=ch:0|w:67|cls:h][/XD][XD=ch:0|w:48|cls:h][/XD][XD=ch:0|w:93|cls:h][/XD][XD=ch:0|w:48|cls:h][/XD][XD=ch:0|w:92|cls:h][/XD][XD=ch:0|w:68|cls:h][/XD][XD=ch:0|w:77|cls:h][/XD][/XR][XR][XD=h:l|fw:b|bc:156082|c:FFFFFF|ch:15|cls:bl bt bb]Some date[/XD][XD=h:l|fw:b|bc:156082|c:FFFFFF|cls:bt bb]Value[/XD][XD=h:l|fw:b|bc:156082|c:FFFFFF|cls:bt bb]sys posting date[/XD][XD=h:l|fw:b|bc:156082|c:FFFFFF|cls:bt bb]Client[/XD][XD=h:l|fw:b|bc:156082|c:FFFFFF|cls:bt bb]Invoice Number[/XD][XD=h:l|fw:b|bc:156082|c:FFFFFF|cls:bt bb]Tax regime[/XD][XD=h:l|fw:b|bc:156082|c:FFFFFF|cls:bt br bb]Product item[/XD][/XR][XR][XD=bc:C0E6F5|ch:15|cls:bl bt bb|tx:45666|nf:m/d/yyyy]9/01/2025[/XD][XD=bc:C0E6F5|cls:bt bb]500[/XD][XD=bc:C0E6F5|cls:bt bb|tx:45682|nf:m/d/yyyy]25/01/2025[/XD][XD=h:l|bc:C0E6F5|cls:bt bb]ACME[/XD][XD=bc:C0E6F5|cls:bt bb]20250126-00001[/XD][XD=h:l|bc:C0E6F5|cls:bt bb]A[/XD][XD=h:l|bc:C0E6F5|cls:bt br bb]ITM-CRD-5478[/XD][/XR][XR][XD=ch:15|cls:bl bt bb|tx:45667|nf:m/d/yyyy]10/01/2025[/XD][XD=cls:bt bb]742[/XD][XD=cls:bt bb|tx:45682|nf:m/d/yyyy]25/01/2025[/XD][XD=h:l|cls:bt bb]MYC°[/XD][XD=cls:bt bb]20250126-00002[/XD][XD=h:l|cls:bt bb]A[/XD][XD=h:l|cls:bt br bb]ITM-BKE-3651[/XD][/XR][XR][XD=bc:C0E6F5|ch:15|cls:bl bt bb|tx:45668|nf:m/d/yyyy]11/01/2025[/XD][XD=bc:C0E6F5|cls:bt bb]349[/XD][XD=bc:C0E6F5|cls:bt bb|tx:45682|nf:m/d/yyyy]25/01/2025[/XD][XD=h:l|bc:C0E6F5|cls:bt bb]ACE[/XD][XD=bc:C0E6F5|cls:bt bb]20250126-00003[/XD][XD=h:l|bc:C0E6F5|cls:bt bb]B[/XD][XD=h:l|bc:C0E6F5|cls:bt br bb]ITM-KNF-9999[/XD][/XR][/RANGE]

Queyr with applied selection referring to that list.
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="sys_export"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Some date", type datetime}, {"Value", Int64.Type}, {"sys posting date", type datetime}, {"Client", type text}, {"Invoice Number", type text}, {"Tax regime", type text}, {"Product item", type text}}),
    Custom1 = Table.SelectColumns(#"Changed Type", col_to_select)
in
    Custom1

If with formatting , you mean data types, the you can create a list of lists. Where the inner list contains 2 items, the column name and the data type.

Power Query:
//cols_to_select
let
    Source = {
                 {"Some date", Date.Type}
                ,{"Value", Number.Type}
                //,"sys posting date"
                ,{"Client", Text.Type}
                //,"Invoice Number"
                ,{"Tax regime", Text.Type}
                ,{"Product item", Text.Type}
            }
in
    Source

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="sys_export"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,col_to_select),
    Custom1 = Table.SelectColumns(#"Changed Type", List.Transform(col_to_select, each List.First(_)))
in
    Custom1

You can extend the inner lists, so you can have the original name of import, the source or supplier, the to be name and the type.


Thank you for the information - if I were to have a separate spreadsheet with a column of the transaction comments or apart of them so BI table can look up the part and change it to be cleaner how will i go about doing that from what you have given. like do i keep both the raw data sheet and the clean up sheet in the same folder for power bi to look at to get the information that i want the final product to be

Thank you again
 
Upvote 0
Basically for the custom i would want something like:

= if the [GL comment] contains some from the cleanup sheet (sheet 1) column 1 then return result from column 2

so of the GL comments have the same wording or data or has a date so I would want something like if the [GL comment} has anyting containing said comment to look for it on the cleanup sheet

Like if the comment is "transaction summary 1/30/25" i would want the formula to look for transaction each time to change it to lets say MISC

thank you
 
Upvote 0

Forum statistics

Threads
1,226,059
Messages
6,188,637
Members
453,487
Latest member
LZ_Code

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top