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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
mh0916
New Member

Dynamic reference instead of set text

Hello,

I am new to PowerBI and need some help please...

I am looking to dynamically refer to StyleCode column in my CALCULATETABLE formula, instead of only having set text of "FAR2I10". 

Can someone please assist?

Thanks

2016-12-12 (4).png

4 REPLIES 4
v-sihou-msft
Microsoft Employee
Microsoft Employee

@mh0916

 

In Power BI Desktop, we can't use Query Parameter in DAX formula.

 

@MattAllington is correct. In this scenario, it's not a good practice to hard code values for so many fields in your calculations. It's better to put those data fields into Slicer. Your measure will take your selection in slicer to calculate the corresponding result.

 

Regards,

 

 

Thanks all,

 

Can you set a slicer to auto adjust to always filter the last 6 months worth of dates or do you have to manually do this?

 

Much appreciated!

@mh0916

 

You may create a time period slicer in your report. Please refer to: POWER BI – TIME PERIOD SLICER FOR LAST 7 DAYS,LAST 30 DAYS.

 

Regards,

MattAllington
Community Champion
Community Champion

From what I can see in your image, you have some sort of slicer on the same text you are referring to. So just remove the text from your calculatetable statement. 

 

Also, I am sure there is a better way to do what you are doing an hard coding all that logic in your formulas.  Try to think about how you could reshape your data to do what you need.

 

The last 6 months portion should be pushed into a calendar table. The logic for the rest could be either managed before loading (i.e. Only load what's you need) or you could put a flag in the table to indicate if it should be included. Also, something like this would seem simpler

 

=calculate(Sum(table[qty]),filters)

 

also, try to simplify your table names. How about "Sales"



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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.

Top Solution Authors
Top Kudoed Authors