Pivot table with variable

Hello, I encountered an issue while attempting to use a pivot table. I initially created an SQL query, incorporating a variable. However, the pivot table did not function I got (Pivot tables can only be used with aggregated queries). To address this, I utilized the query I had written in a question (Summarize) Consequently, I can now employ the pivot table with the new question. The only challenge is that I've lost the variable in the process. Any guidance on how to address this would be greatly appreciated. Thank you!

Hello, does anyone has some news regarding this topic?