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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
muhammadpathan
Frequent Visitor

dynamic slicer query not updating visual

Dont know what am doing wrong. Dont get why visual not updating

 

First i set 2 parametrs start date and end date 

 

muhammadpathan_0-1711553527211.png

 

Then i updated my query(this works correctly as i expect

the parameters work.  i get the set of data i want from

startdate to end date

 

let
// Retrieve the managed parameters for StartDate and EndDate
StartDateParam = Date.From(StartDate),
EndDateParam = Date.From(EndDate),

// Convert StartDate and EndDate to text with the format 'yyyy-MM-dd'
StartDateText = Date.ToText(StartDateParam, "yyyy-MM-dd"),
EndDateText = Date.ToText(Date.AddDays(EndDateParam, 1), "yyyy-MM-dd"),

// Dynamic parameters for NodeId and EventName
NodeId = 71,
EventName = "Ambient conditions",

// Construct the SQL query string dynamically
QueryString = "SELECT TOP (10000) [RecordTime],[RecordDate], [Value], [VariableName] FROM [myv].[events] WHERE NodeId=" & Text.From(NodeId) &
" AND EventName='" & EventName & "'" &
" AND RecordDate >= '" & StartDateText & "'" &
" AND RecordDate < '" & EndDateText & "'" &
" ORDER BY RecordTime DESC",

// Connect to the database with the dynamic query string
Source = Sql.Database("myserver", "db", [CommandTimeout=#duration(0, 0, 1, 0), Query=QueryString]),

// Step: Group rows by RecordTime
GroupedRows = Table.Group(Source, {"RecordTime"}, {{"AllData", each _, type table [RecordTime=datetime, Value=nullable text, VariableName=nullable text]}}),

// Step: Expand AllData to include Value and VariableName, excluding RecordTime to avoid duplication
ExpandedAllData = Table.ExpandTableColumn(GroupedRows, "AllData", {"Value", "VariableName"}, {"Value", "VariableName"}),

// Step: Change the type of Value to number
ChangedType = Table.TransformColumnTypes(ExpandedAllData,{{"Value", type number}}),

// Step: Pivot the table based on VariableName
PivotedColumn = Table.Pivot(ChangedType, List.Distinct(ChangedType[VariableName]), "VariableName", "Value", List.First)
in
PivotedColumn

 

Then i have created both a StartDateTable and EndDateTable

muhammadpathan_2-1711553814037.png

 

 

 

 

I then bind the bot parameters

muhammadpathan_1-1711553744072.png

 

I then create slicer for both values 

muhammadpathan_3-1711554307294.png

i have a chart but when i move the dates nothing happens i was expecting

 

 

muhammadpathan_5-1711554358694.png

 

data model (do i need to map relationships how would id do this?)

muhammadpathan_6-1711554414816.png

do i need to create a start date and an enddate for the Ambient conditions table  table the join up with my start date and end date.

I was trying to follow this tutorial https://www.youtube.com/watch?v=pXU_SpiBWUA in this theres no relationships between and still works

 

1 REPLY 1
v-heq-msft
Community Support
Community Support

Hi @muhammadpathan ,
Based on your description and the screenshot provided, it appears that you have created an initial and end date similar to the dimension table. However, you don't seem to have established a relationship between the table you want to create the visual object from and the dimension table i.e. record time and startdatetable, enddatetable. if there is no connection between them, then the resulting filter will not work on the visual object either. Of course, you can write dax expressions that use selectedvalue to call the values in the two slicers, which will also allow you to control the visual object without establishing a relationship.

Best regards,

Albert He

 

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

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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