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

dual function

Hi,

Is it possible to use dual function for a dimension?

Thank you in advance,

Larisa

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Syntax for dual() is dual(text, number).

In your calculated dimension,

=dual(Only(Media), Медиа)

both fields are showing only text values


Besides this, the only() function seems a bit strange here. Are you looking for


=aggr( Only(Media), Медиа)


?

View solution in original post

7 Replies
petter
Partner - Champion III
Partner - Champion III

Yes it is. Dimension is only a way a field is used. A field could be used both as a dimension and in a regular expression for a measure. So any field can have all, some or none of its values as dual. The dual is a function to create a dual value. There are no restrictions on the usage of a field with dual values.

Anonymous
Not applicable
Author

Hi,

Could you say why the dual function doesn't work correctly as a dimension in my example?

see the file attached.

Thank you in advance

swuehl
MVP
MVP

Syntax for dual() is dual(text, number).

In your calculated dimension,

=dual(Only(Media), Медиа)

both fields are showing only text values


Besides this, the only() function seems a bit strange here. Are you looking for


=aggr( Only(Media), Медиа)


?

petter
Partner - Champion III
Partner - Champion III

The Dual function will not work as you try to assign two text values. Dual assigns one text value and one numeric value as the compound data value within a field.

Thus you can use Медиа directly without the need for a numeric value. Dimensions does not need to be numeric. They can be pure text/alphanumeric values without a number associated with them. However you could assign a number to be associated with each text value and that will also determine the sort order of the field. But the text-part will what will be displayed in most of the UI.

In you example I would modify the load script to this:

LOAD

     Dual( Медиа , RecNo() ) AS Медиа,

     Dual( Media , RecNo() ) AS Media,    

     Quantity

INLINE [

    Медиа, Media, Quantity

    ТВ, TV, 8

    Радио, Radio, 10

    Пресса, Press, 4

];

Then you could use either Медиа or Media as a dimension without employing the Dual function as that has already been done in your load script. You could of course also assign directly a number for each media instead of using RecNo() as I did.

2015-08-17 #1.PNG

Anonymous
Not applicable
Author

Thank you!

Anonymous
Not applicable
Author

thank you!

sanjay006
Creator
Creator

Sir !

Please short the second dimension alphabetically.