There are no interrelations between these two settings. For example, if rate(http_requests_total{job="api-server"}[5m]) is your PromQL query, it yields a single value when you execute it at a specific point in time. If you have a Grafana dashboard with a 2h time range, then Grafana just repeatedly executes this query at a series of point in times during the past 2 hours, and displays you the result of each query as e.g. a graph.
For example, if the time range of your Grafana dashboard is 2h and the interval is set to 1 minute, then Grafana executes your query 120 times during the time span ranging the past 2 hours. The results of all these queries form a graph and that's what you see in your Grafana dashboard.
The interval with which Grafana executes the query is determined by the Max data points and Min interval settings in the Query options of your Grafana dashboard:

See the explanations about these settings in the Grafana documentation.
Answer from weibeld on Stack OverflowNote: Grafana uses the
query_rangeendpoint of the Prometheus API to repeatedly execute the query over the given time range.
What is the exact fomula of the funtion rate?
How can I understand rate() ?
Applying a rate function to positive and negative changes
Grafana / prometheus: understand rate function - Stack Overflow
Hi everyone, I'm stupid. I can't figure out exactly how to interpret rate() in Prometheus.
node_network_transmit_bytes_total{} is just a counter. Use rate() for a rate. Got it.
rate(node_network_transmit_bytes_total{}[1m]) sounds like it should be interpreted as: "How many bytes were transmitted over a minute", but then there's the time range settings in the upper right. Would "Last 3 hours" mean, the average transmit rate per minute for the last 3 hours?
Basically, could someone explain what: rate(node_network_transmit_bytes_total{}[1m]) with a time range of "Last 3 hours" would indicate? None of the explanations I've found on blogs, etc make sense to my smooth brain. I'm basically just trying to see the transmit rate in Mbps, MB/s, or MB/h, for each node.
Note: In the screenshot, you are using irate instead of rate.
Anyway, both are functions to be used with monotonically incrementing counters and calculate how fast the counter increases. Memory usage is not a counter, it is a gauge, so using (i)rate is not useful. See doc on metric types.
Your graph shows how much the memory usage increases per second, not how much memory is used, what you probably want. You can see that you get a spike in irate each time the memory usage drops instead of increments. This drop is interpreted by (i)rate as a reset of the counter, so after the drop/reset, Prometheus thinks the counter immediately rockets from 0 to the actual memory usage in just a second.
See the docs for irate and the docs for rate
rate() is function to specify the time window for the quantile calculation.
https://prometheus.io/docs/prometheus/latest/querying/functions/#histogram_quantile