Forum Discussion

AMMOORE74's avatar
AMMOORE74
Frequent Visitor
2 years ago

Dax Measure help - Dynamic calculation and row context?

I'm relatively new to Dax and having trouble getting my head around the row context and why my measure doesn't behave as desired.  I've tried chat GPT but didnt' really get anywhere, COPILOT was worthless.....I'm scratching my head and looking for someone that can help explain how this would work.

Below I have summarized the tables and relationships.  All are 1:many relationships

I need to dynamically assign a status/horizon value  to every row in a table visual.

I have a table of "opportunities", it links to Customer, Material and Location tables.

There are whatif parameters for the user to adjust when a record is considered frozen, slush or liquid status.

 

There are three status combinations to check, but to illustrate with just the pseudo code for FROZEN status, I'm thinking along the lines of

var category = get the category from the material table

var monthsuntilstart=get the monthsuntilstart from the summary table

var vfrozenthreshold=switch

                                            when category x return category x frozen threshold parameter value

                                            when category y return category y frozen threshold parameter value

                                            when category z return category z frozen threshold parameter value

                                            

                     

return if(monthsuntilstart<=vfrozenthreshold,"FROZEN","")

 

 

I have a table visual that when I put this in I seem to be losing all row context...that is why I was trying to do the max() iterator with the relatedtable.  I'm just grasping at straws and this feels like it shouldn't be that complicated.

 

 

 

DESIRED OUTPUT

 

1 Reply

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi AMMOORE74 ,

     

    It sounds like you're trying to dynamically assign state to each row in a table visual object based on certain conditions and parameters, and then running into issues with using DAX and row context.

     

    Perhaps you could provide me with the syntax you are using?

     

    This is just a thought, I can't tell if there are any syntax errors.

     

    Sample data and pbix files would be best if you can provide them, remember to remove sensitive information and don't log into your account when uploading pbix files in Power BI Desktop.

     

    If you have any other questions please feel free to contact me.

     

    Best Regards,
    Yang
    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
    If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!