Forum Discussion

mh0916's avatar
mh0916
New Member
9 years ago

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

4 Replies

  • MattAllington's avatar
    MattAllington
    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"

  • v-sihou-msft's avatar
    v-sihou-msft
    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,