Maybe you would benefit from a change of your data structure.
1. A more nested association
Given your initial set:
aData=<|
{"Country1","YEAR1"}->{<|{"VARIABLE1","MEASURE1"}->"Value111"|>,<|{"VARIABLE2","MEASURE2"}->"Value112"|>},
{"Country1","YEAR2"}->{<|{"VARIABLE1","MEASURE1"}->"Value121"|>,<|{"VARIABLE2","MEASURE2"}->"Value122"|>},
{"Country2","YEAR1"}->{<|{"VARIABLE1","MEASURE1"}->"Value211"|>,<|{"VARIABLE2","MEASURE2"}->"Value212"|>},
{"Country2","YEAR2"}->{<|{"VARIABLE1","MEASURE1"}->"Value221"|>,<|{"VARIABLE2","MEASURE2"}->"Value222"|>}|>;
let's turn it into:
newd = KeyValueMap[
Association[#1[[1]] -> Association[#1[[2]] -> #2]] &,
Merge[#, Identity] & /@ aData] // Merge[#, Join @@ # &] &
<|"Country1" -> <|"YEAR1" -> <|{"VARIABLE1",
"MEASURE1"} -> {"Value111"}, {"VARIABLE2",
"MEASURE2"} -> {"Value112"}|>,
"YEAR2" -> <|{"VARIABLE1",
"MEASURE1"} -> {"Value121"}, {"VARIABLE2",
"MEASURE2"} -> {"Value122"}|>|>,
"Country2" -> <|"YEAR1" -> <|{"VARIABLE1",
"MEASURE1"} -> {"Value211"}, {"VARIABLE2",
"MEASURE2"} -> {"Value212"}|>,
"YEAR2" -> <|{"VARIABLE1",
"MEASURE1"} -> {"Value221"}, {"VARIABLE2",
"MEASURE2"} -> {"Value222"}|>|>|>
then you can make more readable query like that:
res=newd[[{"Country2", "Country1"}, {"YEAR1", "YEAR2"}, Key@{"VARIABLE1", "MEASURE1"}]]
<|"Country2" -> <|"YEAR1" -> {"Value211"}, "YEAR2" -> {"Value221"}|>,
"Country1" -> <|"YEAR1" -> {"Value111"}, "YEAR2" -> {"Value121"}|>|>
and to get the output you want:
Level[MapIndexed[Join /* RotateLeft, res, {2}], {2}] /. Key -> Identity
{{"Country2", "YEAR1", "Value211"}, {"Country2", "YEAR2", "Value221"}, {"Country1", "YEAR1", "Value111"}, {"Country1", "YEAR2", "Value121"}}
2. A Flat association
But why not try a flat association ?
flat = Flatten@
Table[<|"Country" -> "C" <> ToString@i,
"Year" -> "Y" <> ToString@j,
"VarMeas" -> "VM" <> ToString@k|>, {i, 2}, {j, 2}, {k, 2}]
{
<|Country->C1,Year->Y1,VarMeas->VM1|>,
<|Country->C1,Year->Y1,VarMeas->VM2|>,
<|Country->C1,Year->Y2,VarMeas->VM1|>,
<|Country->C1,Year->Y2,VarMeas->VM2|>,
<|Country->C2,Year->Y1,VarMeas->VM1|>,
<|Country->C2,Year->Y1,VarMeas->VM2|>,
<|Country->C2,Year->Y2,VarMeas->VM1|>,
<|Country->C2,Year->Y2,VarMeas->VM2|>}
Then
Query[
Select[
(MemberQ[{"C1", "C2"}, #Country] && MemberQ[{"Y1"}, #Year]) &
],
{"Country", "Year", "VarMeas"}]@flat // Values
{{"C1", "Y1", "VM1"}, {"C1", "Y1", "VM2"}, {"C2", "Y1", "VM1"},{"C2","Y1", "VM2"}}