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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
Minseven07
Frequent Visitor

get value based on dynamic column

hi all,

 

i want to get a value from a table based on a dynamic columns name. Here is the context:

 

my tables are linked this way:

Minseven07_0-1706865910015.png

 

here is an example of structure info:

Minseven07_1-1706865948041.png

 

as you can see, the column year is what i want to get.

 

the matrix on my report should looks like this:

Minseven07_2-1706866006476.png

 

i tried something like this:

VAR CurrentYear = SELECTEDVALUE('PGI_export_xls'[date].[Year]) // get the year
 
but then i'm stuck. I don't see how to get the value from the column_name = CurrentYear
there is a SWITCH method where i can test dynamically if the column name match the CurrentYear
 
CurrentYear = 2022, 'structure_info'[2022],
 
but that's not what i call dynamic, especially if i have many columns.
 
thx
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Minseven07 , You should unpivot the year columns in the power query

 

Unpivot Data(Power Query): https://youtu.be/2HjkBtxSM0g

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Minseven07 , You should unpivot the year columns in the power query

 

Unpivot Data(Power Query): https://youtu.be/2HjkBtxSM0g

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

I have tried this but i have unpivoted the years column and the id. Unpivoting just the years worked! You rock! Thanks

Helpful resources

Announcements
September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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