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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
elia22gr
Helper III
Helper III

dynamic column reference in an if statement

Hi all,

 

I have a following problem. In my company we have dynamic changing targets. For Example this month the target is on Products from Cat1 (this is under CATEGORY_1 column) and Br1 (this is under BRAND column) and PT1 (this is under PackType column) and the next month the target would be for products from SubCat2 (this is under SUBCATEGORY column) and PS2 (this is under PackSize column). 

CATEGORY_1, BRAND, PackType, SUBCATEGORY, PackSize are column in my Dim_Products Query.
I want to add a conditional column in my Dim_Products Table to use it as filter in my report, where it will bring 1 when the target conditions are met and 0 otherwise.

I have a Target_Mapping Table where I have the columns Names from my Dim_Products table and the value. 

NameColumn_Name_1Value_1Column_Name_2Value_2Column_Name_3Value_3
Target_SeptemberCATEGORY_1Cat_1BRANDBr1PackTypePT1

 How can I write the if statement in my Dim_Products table
Instead of hard-coding the [CATEGORY_1], [BRAND], [PackType] the columns reference to change it with the refence of the Target_Mapping Table under columns with header starting with "Column_Name_", picking each time the first row and put it as column reference in the if statement and as value again picking whatever is in the first row of columns with headers starting with "Value_".
if [Column_Name_1 first row] = Value_1 first row and [Column_Name_2 first row] = Value_2 first row and [Column_Name_3 first row] = Value_3 first row then 1 else 0

Thank you in advance,

Eleftheria

1 REPLY 1
lbendlin
Super User
Super User

Please provide sample data (with sensitive information removed) that covers your issue or question completely, in a usable format (not as a screenshot). Leave out anything not related to the issue.
If you are unsure how to do that please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Please show the expected outcome based on the sample data you provided.

If you want to get answers faster please refer to https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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.