jafa1970
New member
- Joined
- Jan 4, 2016
- Messages
- 22
- Reaction score
- 0
- Points
- 0
- Excel Version(s)
- Office 365
Hi, I want to be able to control filtering of a dataset by using a parameter table to define which column to use ("Unit Type"), and which value to filter by ("Unit Name"). I have the following code which works, but is extremely slow. Can anyone suggest an alternative approach?
I then filter the [Unit Filter] field to keep the "1" values. I did try just having the result being TRUE / FALSE, rather than setting to 1 or 0, but that was just a slow.
Thanks in advance,
Phil
Code:
= Table.AddColumn(Source, "Unit Filter", each if fnGetParameter("Unit Type") = "COMPANY" then (if fnGetParameter("Unit Name") = [COMPANY_NAME] then 1 else 0)
else
if fnGetParameter("Unit Type") = "CENTRE" then (if fnGetParameter("Unit Name") = [CENTRE_NAME] then 1 else 0)
else
if fnGetParameter("Unit Type") = "SECTION" then (if fnGetParameter("Unit Name") = [SECTION_NAME] then 1 else 0)
else
0)
I then filter the [Unit Filter] field to keep the "1" values. I did try just having the result being TRUE / FALSE, rather than setting to 1 or 0, but that was just a slow.
Thanks in advance,
Phil