Customize Data File param with Page .Params

Hi, I would like to call different Site data File using page .Params.

I have data file like:
foo/category/filename/filename.md
foo/category/filename2/filename2.md
foo/category2/filename/filename.md
foo/category2/filename2/filename2.md

I can call it in type/single.html in partial like:

{{ $foo := $.Site.Data.foo.category.filename }}
and range through it:
{{ range $foo }} {{ partial "photo-gallery" . }} {{ end }}

I would like to customize and call different data file depending on page .Params,
I figured out that I can customize it like:
in page.md file:
myvalue: "filename"
and I can call it using:
{{ $foo := index $.Site.Data.foo.category Params.myvalue }}
and it works
but I would like to customize in page params category name too, like:
in page.ms file:
myvalue: "category/filename"

and try call it like:
{{ $foo := index $.Site.Data.foo Params.myvalue }}

how can I achieve it?
I’m beginner with hugo so I’d be grateful for help :slightly_smiling: