Skip to main content
Solved

Create A HREF based on dataset filters

  • July 31, 2025
  • 1 reply
  • 21 views

danny.oneill

I have a little code block on a custom view/code page which links to the dataset. See below:

<div class="advanced-kpi--bottom">
<div class="advanced-kpi--bottom-second-stage">
<a class="source"
href="/explore/dataset/{{ ctx.dataset.datasetid }}/table/" target="_blank" rel="noopener norefer">
View Source <i class="fa fa-long-arrow-right" aria-hidden="true"></i>
</a>
</div>
</div>

I would like the href to be dynamic to either use the refine in the dataset context parameters or based on some on page filters. See this page for the filters in question: https://cityobservatory.birmingham.gov.uk/explore/dataset/percentage-households-in-fuel-poverty-wmca-wards/insight/

Is this possible? The URL sync is on if that helps. Or do I need to hard code the refine.arealabel into the URL path?

Best answer by Thomas R.

Hello Danny,

 

In order to do that you’ll need to use a specific function to get parameters out of the filtered context.

 

<div class="advanced-kpi--bottom">
<div class="advanced-kpi--bottom-second-stage">
<a class="source"
href="/explore/dataset/{{ ctx.dataset.datasetid }}/table/?{{ctxfiltered.getQueryStringURL()}}" target="_blank" rel="noopener norefer">
View Source <i class="fa fa-long-arrow-right" aria-hidden="true"></i>
</a>
</div>
</div>

 

This is described in the documentation in the Properties of odsDatasetContext used as variable section if you want to dig more on the topic.

 

Best regards,

Thomas 

1 reply

Thomas R.
Huwise Team
  • Huwise Team
  • 6 replies
  • Answer
  • July 31, 2025

Hello Danny,

 

In order to do that you’ll need to use a specific function to get parameters out of the filtered context.

 

<div class="advanced-kpi--bottom">
<div class="advanced-kpi--bottom-second-stage">
<a class="source"
href="/explore/dataset/{{ ctx.dataset.datasetid }}/table/?{{ctxfiltered.getQueryStringURL()}}" target="_blank" rel="noopener norefer">
View Source <i class="fa fa-long-arrow-right" aria-hidden="true"></i>
</a>
</div>
</div>

 

This is described in the documentation in the Properties of odsDatasetContext used as variable section if you want to dig more on the topic.

 

Best regards,

Thomas