Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Using a dimension as a variable

Hi everyone,

I have seen lots of examples of using variables as a dimension, but I want to use the dimension of my chart as a variable!

I am creating a football team visualisation and I currently have two tables - one with match results (containing HomeTeam, AwayTeam) and another with all possible teams (Team). I am trying to use Team as a dimension but this means that I cannot simply add up either Home Goals or Away Goals to work out how many goals they have scored, as this would add up all the goals scored in any match they have played and not just the goals they have scored!

I have worked around this when I have selected a particular team by using the set analysis:

     SUM({<HomeTeam = {"$(=GetFieldSelection(Team))"}>} FTHG)

and this works great! (FTHG = Full Time Home Goals).

However, when I try to use this in the chart there is no current Team selected, so this doesn't work, nor does simply HomeTeam = Team. Can anyone please help me on this?!

Ross

2 Replies
swuehl
MVP
MVP

How does your input table or data model look like?

Here is a similar request, probably built up on a different table structure, but maybe you can adapt to your needs:

Sum goals a team has suffered

Anonymous
Not applicable
Author

Hi Stefan,

Unfortunately it's not the same problem. My problem is that I need to use the dimension of the chart as a variable in my chart expression.

FYI, one of my tables has:

Date, HomeTeam, AwayTeam, Result, Full Time Home Goals, Full Time Away Goals, Home Shots, Away Shots etc...

The other table has:
Team, BackgroundRGB, TextRGB, OutlineRGB, PictureLink etc.

The team is in the same format as HomeTeam and AwayTeam - so when team is selected, I have used it as a variable [ "GetFieldSelections($(=Team))" ] to select when Team = HomeTeam, however when Team is used as a dimension in a chart it seems as if it's not actually selecting a Team so this can't be used.