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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
jjkiernanNGDS
Advocate I
Advocate I

Field Parameters - Returned using IF or Switch

Hi, I have a slicer which has a table of field parameters. I have a situation, that in a particular case, I want to show additional fields on the field parameter when a specific value is selected ( in my code below, a selected company code) I.E when that company code is selected there are 6 field parameters , otherwise only 4. I have tried this using a simple IF statement and also with Switch. I get the same error - Expression refers to multiple columns. Multiple columns cannot be converted to scalar values. I understand I'm trying to return a table, thats what i want to do. 

Is there any method to have the table return in the DAX. I'm assuming not, but just in case there's a means of doing this. 

Category Selection Fields =
VAR TableA= {    ("Customer", NAMEOF('DimCustomers'[NAME]), 0),
    ("Country", NAMEOF('DimCustomers'[COUNTRY]), 1),
    ("Sales Rep", NAMEOF('SalesPersons'[SALESMAN_NAME]), 2),
    ("Product Group", NAMEOF('ProductGroups'[Product Category]), 3)
}
VAR TableB = {    ("Customer", NAMEOF('DimCustomers'[NAME]), 0),
    ("Country", NAMEOF('DimCustomers'[COUNTRY]), 1),
    ("Region", NAMEOF('FCTOrders'[REGION_CODE]), 2),
    ("Sales Rep", NAMEOF('SalesPersons'[SALESMAN_NAME]), 4),
    ("Product Group", NAMEOF('ProductGroups'[Product Category]), 5),
    ("District", NAMEOF('FCTOrders'[DISTRICT_NAME]), 3)
}

RETURN IF(SELECTEDVALUE(GroupCompanies[Company_Code])=203,TableB,TableA)
 

 

7 REPLIES 7
titusissam
Frequent Visitor

Hi there, Good Day..

I tried this work around by adding a new column to field parameter and used the newly added column to my main table slicer.. this way I was able to control my Parameter values.
 
Just tried this and felt it worked for me, but I havent tested this extensively. your thoughts here is appreciated.

{    (
"Customer"NAMEOF('DimCustomers'[NAME]), 0, "Table1"),
    ("Country"NAMEOF('DimCustomers'[COUNTRY]), 1, "Table1"),
    ("Sales Rep"NAMEOF('SalesPersons'[SALESMAN_NAME]), 2, "Table1"),
    ("Product Group"NAMEOF('ProductGroups'[Product Category]), 3, "Table1"),
 
("Customer"NAMEOF('DimCustomers'[NAME]), 0, "Table2"),
    ("Country"NAMEOF('DimCustomers'[COUNTRY]), 1, "Table2"),
    ("Sales Rep"NAMEOF('SalesPersons'[SALESMAN_NAME]), 2, "Table2")
}
viraj_arsekar
Helper I
Helper I

I'm trying to do the exact same thing. My code looks very much similar to this. Select 4 paramerts if "Yes" is selected in one of the slicers, or select 6 parameters. Using this paramet in the table cloumns. Table will show either 4 or 6 columns depending on what is selected in the slicers. It looks so simple, but IF and SWITCH do not work, it gives me the same erros. I wish it worked, would have been amazing to do such conditional displaying of columns and parameters. Tried many things, no luck.

Anonymous
Not applicable

Did you ever solve this looking to do the same thing?

I didn't solve the issue in this particular way. And designed my report in a different manner. However, I recently seen a Video by Bas on How to Power BI, which uses Disconnected tables and some measures, to determine which Items to show in a slicer which would have worked for my use case. 

https://youtu.be/NqlgTXCfqSs?si=COG1C6YbFIlVIMoP

Thanks for sharing. I was able to use the logic in this video to achieve what I needed. Only thing it got much complicated, would have been so simple if IF or SWITCH worked in the DAX for parameter.

amitchandak
Super User
Super User

@jjkiernanNGDS , if you need selected value, I explained that in community webinar and shared the file in one of the comment

https://community.powerbi.com/t5/Webinars-and-Video-Gallery/Power-BI-Community-Show-Episode-10-Makin...

 

This blog also have the code

https://amitchandak.medium.com/switch-topn-with-field-parameters-299a0ae3725f

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks for coming back, however i am trying to make the Field Parameters Dynamic using a standard selected slicer value, I'm not trying to find selected Field Parameter value either. 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.