Shiny App- problem with filter-modul and database quiery

Hello everyone,
I'm working on a shiny app. I want to filter data from our database using a json interface (webjason). I'm having trouble setting up the filter module so that I can actually see the measured values ​​in my graph. Can anyone help me?
You go through the filter from top to bottom and then when you click on "Apply filter (Filter anwenden)". you see the filtered data in the plot.

####Filtermodul - ui und server####

#Datenabfrage

Parameterdaten<-data.frame(fromJSON("http://XXX.XX.XX.XX/WebJSON/parameters?program=RMP_Chemie"))
Parametergruppen<-data.frame(fromJSON("http://XXX.XX.XX.XX/WebJSON/parameterGroups?"))

####Dashboard-Ui####

dashboardBody(
tabItems(
tabItem(tabName = "Datenvisualisierung",
fluidPage(
sidebarLayout(
sidebarPanel(
style = "background-color: #CCCCCC;",

            selectInput("station", "Messstation auswählen", choices = unique(statdaten$monitoringSites.name), multiple = TRUE),
            
            selectInput("parameterAuswahl", "Parameter auswählen:",
                        choices = unique(Parameterdaten$parameters.name), multiple = TRUE),
            dateRangeInput("datumsAuswahl", "Datum auswählen:",
                           start = "2023-01-01", end = "2023-12-31",
                           format = "dd.mm.yyyy"), 
            actionButton("filter_btn1", "Filter anwenden")),
          
          mainPanel(
            box(
              width = 12, 
              title = "Grafikübersicht", 
              heigth = "200px",
              plotlyOutput("plotly_plot")
            ))),

###server####

####Filtermodul####

filtered_data <- eventReactive(input$filter_btn1, {
filtered <- data
if (!is.null(input$station) && input$station != "Alle") {
filtered <- filtered[filtered$Messstation == input$station, ]
}
if (!is.null(input$stoff) && input$stoff != "Alle") {
filtered <- filtered[filtered$Stoff == input$stoff, ]
}
filtered <- filtered[filtered$Jahr >= input$jahr[1] & filtered$Jahr <= input$jahr[2], ]
return(filtered)

)}

filter date
filtered_data <- eventReactive(input$filter_btn1, {
filtered_data <- daten %>%
filter(Datum >= input$datumsAuswahl[1] & Datum <= input$datumsAuswahl[2])

if (input$phaseAuswahl != " ") {
  filtered_data <- filtered_data %>%
    filter(Phase == input$phaseAuswahl)
}

if (input$parameterAuswahl != " ") {
  filtered_data <- filtered_data %>%
    filter(Parameter == input$parameterAuswahl)
}

filtered_data

})

plot

output$plotly_plot <- renderPlotly({
plot_ly(data, x = ~Datum, y = ~Wert, type = 'scatter', mode = 'lines') %>%
layout(title = "Kupfer (mg/l)",
xaxis = list(title = "Datum"),
yaxis = list(title = "Wert"))
})

It looks like you need to combine your filter logic in your server. You are currently creating the filtered_data reactive twice, tied to the same input$filter_btn1 trigger. Additionally, you aren't adding the data argument correctly in your renderPlotly() call. Since the data you wish to plot is a reactive, you call it like a function (filtered_data()) to access it.

This isn't runnable code since there's no provided MRE for your app structure, but hopefully this points you in a better direction for troubleshooting.

server <- function(input, output) {
  # Parameterdaten <- data.frame(fromJSON("http://XXX.XX.XX.XX/WebJSON/parameters?program=RMP_Chemie"))
  # Parametergruppen <- data.frame(fromJSON("http://XXX.XX.XX.XX/WebJSON/parameterGroups?"))
  
  filtered_data <- eventReactive(input$filter_btn1,{
    req(input$datumsAuswahl, input$jahr)
    
    Parameterdaten |> 
      dplyr::filter(
        dplyr::between(Datum, input$datumsAuswahl[1], input$datumsAuswahl[2]),
        dplyr::between(Jahr, input$jahr[1], input$jahr[2]),
        dplyr::if_else(
          req(input$station) != "Alle",
          Messstation == input$station,
          Messstation == Messstation
        ),
        dplyr::if_else(
          req(input$stoff) != "Alle",
          Stoff == input$stoff,
          Messstation == Messstation
        ),
        dplyr::if_else(
          req(input$phaseAuswahl) != " ",
          Phase == input$phaseAuswahl,
          Phase == Phase
        ),
        dplyr::if_else(
          req(input$parameterAuswahl) != " ",
          Phase == input$parameterAuswahl,
          Parameter == Parameter
        )
      )
  })
  
  output$plotly_plot <- renderPlotly({
    plot_ly(filtered_data(), x = ~Datum, y = ~Wert, type = 'scatter', mode = 'lines') %>%
      layout(title = "Kupfer (mg/l)",
             xaxis = list(title = "Datum"),
             yaxis = list(title = "Wert"))
  })
}

Also take a look at req() and dplyr::if_else().

Thank you so so so much!!!
I will try it :))