Environment
I am using copilot studio, generative responses, using Run a query against a dataset within a topic, publishing agent to Teams.
My problem
I can put the DAX Evaluate query into the Run a query against a dataset input field with hard coded params and everything works. The user can ask a question, the topic triggers, the query runs and returns the results. I need to now dynamically change the parameter values using variables set/extracted from the user input. I can extract the values from user input fine, and have them stored in variables, but i am unable to properly replace the placeholders in the DAX.
My two topic variables captured are Topic.Timeframe and Topic.Location. How do insert them into the DAX below. I have tried Topic.Timeframe, {Topic.Timeframe}, {{Topic.Timeframe}}, """Topic.Timeframe""" etc, but i cannot get the syntax right.
Please note: I cannot use Fabric & MCP, and it is not yet supported in MS Teams.
EVALUATE
VAR __Timeframe = "Topic.Timeframe"
VAR __LocationCode = "Topic.Location"
VAR __Today = TODAY()
VAR __WeekStart = __Today - WEEKDAY(__Today, 2) + 1
VAR __WeekEnd = __WeekStart + 6
VAR __NextWeekStart = __WeekStart + 7
VAR __NextWeekEnd = __WeekEnd + 7
VAR BaseTable =
FILTER(
'view1',
'view1'[LocationCode] = __LocationCode
&&
SWITCH(
__Timeframe,
"today",
INT('view1'[EventDate]) = __Today,
"tomorrow",
INT('view1'[EventDate]) = __Today + 1,
"this week",
INT('view1'[EventDate]) >= __WeekStart
&& INT('view1'[EventDate]) <= __WeekEnd,
"next week",
INT('view1'[EventDate]) >= __NextWeekStart
&& INT('view1'[EventDate]) <= __NextWeekEnd,
INT('view1'[EventDate]) = __Today
)
)
RETURN
SELECTCOLUMNS(
BaseTable,
"LocationCode", [LocationCode],
"EventDate", [EventDate],
"EventStartTime", [EventStartTime],
"DeceasedName", [DeceasedName],
"EventStatus", [EventStatus]
)
ORDER BY [EventDate]