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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
sbellmore
Frequent Visitor

How to make Dynamic Key column that changes to formula based on user selection?

I have two Tables These are simplified... 

The table with Formulas (this table is Called Table1)

Custom     Custom.1

Option 1[Source System]&[FY]&[BN]&[BS]&[Fnd]&[Pg]
Option 2[Source System]&[FY]&[BN]&[BS]&[Fnd]&[Pgr]&[AP]]

 

 

and the table I am trying to make the Dynamic Key Column in: (Table2)

Source SystemSOFTransaction FYFYBNBSFndPgAFPAllotmentCommitmentsObligationsExpensedDisbursementsAPOAMDEPCI
System1D2024244012140120D4BASE1234123412341234123412341056786AVHMN43006
System2D2024242025120250D4BASE12341234123412341234123412163486ATACS24767
System3D2024241205112050024BASE123412341234123412341234131282096ALOMGA567J
ETCD2024242025120251024BASE123412341234123412341234111342046APERN7457

 

2.  This is the first formula to know the user selection Option 1:

SelectedFormula = SELECTEDVALUE('Table1'[Custom])  - when i view this in a table I verify that Option 1 is selected. 
 
and the second formula. 
 
ConcatenatedKey =
SWITCH (
SELECTEDVALUE('Table'[Custom]),
"Option 1", CONCATENATEX(SUMMARIZE('Table2', [Source System], [FY], [BN], [Fnd], [Pg]), [Source System] & [FY] & [BN] & [Fnd]& [Pg], ", "),
"Option 2", CONCATENATEX(SUMMARIZE('Tablel2', [Source System], [FY], [BN], [Fnd], [Pg], [AP]), [Source System] & [FY] & [BN] & [Fnd] & [Pg] & [AP], ", "),
BLANK()
)
UPDATE^: This works as a measure but I Cant put this in a table....  the end goal is to have a dynamic key in both tables to do a merge off of, this will allow the user to choose different level of detailed analysis by selecting how to define the key. 
 

ConcatenatedKey =

SWITCH (

    [SelectedFormula],

    "Option1", CONCATENATEX('Table2', [Source System] & [FY] & [BN] & [Fnd] & [Pg]),

    "Option2", CONCATENATEX('Table2', [Source System] & [FY] & [BN] & [Fnd] & [Pg] & [AP]),

    BLANK()

)

 

But When I assign the Concatenated Key to a column in Table2, it returns no value. Its blank for every row. As I said above, trying to find a way to provide the user to select different levels of detailed analysis. If i need a different approach please let me know! 

 

The value held by Selected formula  when Option 1 is selected is Option 1

 

any help would be appreciated

2 REPLIES 2
v-yifanw-msft
Community Support
Community Support

Hi @sbellmore ,

You are on the right track in terms of usage and functionality based on the information you provide.Metrics in Power BI change dynamically based on slicer selections. Metrics are recalculated based on slicer selections and can reflect current user selections.

You can add Custom to the slicer and select Option to make the measure change automatically as needed.

vyifanwmsft_0-1711072158262.png

Final output:

vyifanwmsft_1-1711072185371.png

vyifanwmsft_2-1711072202425.png

How to Get Your Question Answered Quickly - Microsoft Fabric Community

If it does not help, please provide more details with your desired out put and pbix file without privacy information.

 

Best Regards,

Ada Wang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hey! 

 

Thanks for the response, it works when you add the metric to a visual. But I guess I need something in Power Query to do the same thing... In Table view on Power BI, If i Go back to Table2, and add column and add column = Concatenated Key  -> the result is blank for the entire column. Thats where my problem is. I would like to add it as a column to each table and then do an inner join off that column to get a predifned table with different levels of analysis. not sure if I am asking too much. I very well may be, but I am just trying to teach myself a way to do this. If it is even possible. Thank you So much!

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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