If statement not working in advanced editor

shlobodon

New Member
Joined
Oct 15, 2015
Messages
44
I am trying to create a dynamic workbook that will update data depending on which "Location" is selected from a drop down list. I was able to create it, but I want to take it a bit further.

I want the workbook to show all available data, not just data pertaining to a location, if the drop down list is blank. I am struggling with the if statement needed to create this. My code is below

let
Table2 = let
Source = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],
Location2 = Excel.CurrentWorkbook(){[Name="Location2"]}[Content],
#"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Calendar month", Int64.Type}, {"Ship:Cust Bus Area 3", type text}, {"Ship:Cust Bus Area 1", type text}, {"Ship:Cust Bus Area 2", type text}, {"Ship:Cust Bus Area 4", type text}, {"Ship:Cust Bus Area 5", type text}, {"Receive Method", type text}, {"Prod Category", type text}, {"Material Type", type text}, {"Material Group", type text}, {"Product hier.lev. 1", type text}, {"VAS Code", Int64.Type}, {"Company code", Int64.Type}, {"Sales Amount", type number}, {"Sales Amount_1", type number}}),
#"Renamed Columns" = Table.RenameColumns(#"Changed Type",{{"Ship:Cust Bus Area 3", "ShipCust Bus Area 3"}})
in
#"Renamed Columns",
Source = Excel.CurrentWorkbook(){[Name="Table2"]}[Content],
Location2 = Excel.CurrentWorkbook(){[Name="Location2"]}[Content],
#"idkwhatdoing" = if Excel.CurrentWorkbook(){[Name="Location2"]}[Content] = null then Table.SelectRows(Table2)
else Table.SelectRows(Table2, each ([ShipCust Bus Area 3] = Excel.CurrentWorkbook(){[Name="Location2"]}[Content]{0}[Column1]))
in
#"idkwhatdoing"

The if statement I am having issues with is in red. I believe there is some kind of format issue where even though the drop down list cell is blank, it is not being registered as null. Ironically, when the else is carried out, the same value not identified as null pulls null data from the data source.
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
could you post a link to the shared excel file with your data, via dropbox, onedrive, googledrive or any similar?
 
Upvote 0
i may be able to a bit later.

do you know anything that could make Excel.CurrentWorkbook(){[Name="Location2"]}[Content] recognizable? like VALUE(Excel.CurrentWorkbook(){[Name="Location2"]}[Content]).
 
Upvote 0
i got it. format that worked was Excel.CurrentWorkbook(){[Name="Location2"]}[Content]{0}[Column1] = null how could i have forgotten [0][Column1]!!!!???!?!? so silly of me

feel like a toddler with one of those wooden puzzles that are only like 3 large pieces
 
Upvote 0

Forum statistics

Threads
1,214,924
Messages
6,122,293
Members
449,077
Latest member
Rkmenon

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