Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
vikasmahajan

GetObjectField() function with Max () dimension

Hi Team

I am trying to build dynamic market share based on user selected dimensions I need last selected dimension in my formula :

 

Num( Sum({<New_Flag_YTD = {1},MonthNumber = { $(=$(vMaxMonth))}>} Sales_Dollars)
/Sum(Total <$(=getobjectfield(max(Dimensionality()-2))> {<New_Flag_YTD = {1},MonthNumber = { $(=$(vMaxMonth))}>} Sales_Dollars),'##.##%')

How to achieve this any help highly appreciated.

Thanks in Advance.

 

Vikas

Hope this resolve your issue.
If the issue is solved please mark the answer with Accept as Solution & like it.
If you want to go quickly, go alone. If you want to go far, go together.
Labels (5)
1 Solution

Accepted Solutions
andrey_krylov
Specialist
Specialist

and with var vLastDim

    SubField( $(=''''&
    If(Len(GetObjectField(0)) > 0, ',' & GetObjectField(0))
& If(Len(GetObjectField(1)) > 0, ',' & GetObjectField(1))
& If(Len(GetObjectField(2)) > 0, ',' & GetObjectField(2))
& If(Len(GetObjectField(3)) > 0, ',' & GetObjectField(3))
& If(Len(GetObjectField(4)) > 0, ',' & GetObjectField(4))
& If(Len(GetObjectField(5)) > 0, ',' & GetObjectField(5))
& If(Len(GetObjectField(6)) > 0, ',' & GetObjectField(6))
& If(Len(GetObjectField(7)) > 0, ',' & GetObjectField(7))
& If(Len(GetObjectField(8)) > 0, ',' & GetObjectField(8))
& If(Len(GetObjectField(9)) > 0, ',' & GetObjectField(9))
&'''' ), ',', -1 )

Num( Sum({<New_Flag_YTD = {1},MonthNumber = { $(=$(vMaxMonth))}>} Sales_Dollars)
/Sum(Total <[$(=$(vLastDim))]> {<New_Flag_YTD = {1},MonthNumber = { $(=$(vMaxMonth))}>} Sales_Dollars),'##.##%')

andrey_krylov_0-1666385010246.png

 

View solution in original post

5 Replies
andrey_krylov
Specialist
Specialist

Hi Vikas. The problem is that Dimensionality()  does not correspond exactly to GetObjectField(). So if there are hidden dims GetObjectField counts them but returns empty values. Try this expression

=Pick(Max(Dimensionality())
$(=If(Len(GetObjectField(0)) > 0, ', ''' & GetObjectField(0) & '''')
& If(Len(GetObjectField(1)) > 0, ', ''' & GetObjectField(1) & '''')
& If(Len(GetObjectField(2)) > 0, ', ''' & GetObjectField(2) & '''')
& If(Len(GetObjectField(3)) > 0, ', ''' & GetObjectField(3) & '''')
& If(Len(GetObjectField(4)) > 0, ', ''' & GetObjectField(4) & '''')

// and so on up to NoOfDims
 ) )

 

andrey_krylov_0-1666361016048.png

andrey_krylov_0-1666361652899.png

 

andrey_krylov
Specialist
Specialist

Or wothout Dimensionality

=[$(=SubField( $(=''''&
If(Len(GetObjectField(0)) > 0, ',' & GetObjectField(0))
& If(Len(GetObjectField(1)) > 0, ',' & GetObjectField(1))
& If(Len(GetObjectField(2)) > 0, ',' & GetObjectField(2))
& If(Len(GetObjectField(3)) > 0, ',' & GetObjectField(3))
& If(Len(GetObjectField(4)) > 0, ',' & GetObjectField(4))
& If(Len(GetObjectField(5)) > 0, ',' & GetObjectField(5))
& If(Len(GetObjectField(6)) > 0,',' & GetObjectField(6))
&'''' ), ',', -1 ) )]

andrey_krylov_0-1666367593309.png

 

 

 

andrey_krylov
Specialist
Specialist

and with var vLastDim

    SubField( $(=''''&
    If(Len(GetObjectField(0)) > 0, ',' & GetObjectField(0))
& If(Len(GetObjectField(1)) > 0, ',' & GetObjectField(1))
& If(Len(GetObjectField(2)) > 0, ',' & GetObjectField(2))
& If(Len(GetObjectField(3)) > 0, ',' & GetObjectField(3))
& If(Len(GetObjectField(4)) > 0, ',' & GetObjectField(4))
& If(Len(GetObjectField(5)) > 0, ',' & GetObjectField(5))
& If(Len(GetObjectField(6)) > 0, ',' & GetObjectField(6))
& If(Len(GetObjectField(7)) > 0, ',' & GetObjectField(7))
& If(Len(GetObjectField(8)) > 0, ',' & GetObjectField(8))
& If(Len(GetObjectField(9)) > 0, ',' & GetObjectField(9))
&'''' ), ',', -1 )

Num( Sum({<New_Flag_YTD = {1},MonthNumber = { $(=$(vMaxMonth))}>} Sales_Dollars)
/Sum(Total <[$(=$(vLastDim))]> {<New_Flag_YTD = {1},MonthNumber = { $(=$(vMaxMonth))}>} Sales_Dollars),'##.##%')

andrey_krylov_0-1666385010246.png

 

vikasmahajan
Author

Thanks for your solution let me try and mark as a accepted solution.

Many thanks

Vikas

Hope this resolve your issue.
If the issue is solved please mark the answer with Accept as Solution & like it.
If you want to go quickly, go alone. If you want to go far, go together.
vikasmahajan
Author

Thank you so much Andrey this what exactly I was looking for!!

Vikas

 

Hope this resolve your issue.
If the issue is solved please mark the answer with Accept as Solution & like it.
If you want to go quickly, go alone. If you want to go far, go together.