Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
achitreskyitgroup
Partner - Contributor II
Partner - Contributor II

Maximum Length of row in a column

Hello,

How can we find the max len of the data in each column?

 

Example:

tbl:

LOAD * INLINE [

    Year, Week, Purchase

    2012, 21, 15000

    2012, 22, 24000

    2012, 33, 55000

    2013, 1, 15000

    2013, 2, 24000

    2013, 3, 16000

    2013, 24, 103560

    2013, 25, 563200

];

 

Should give me

$ Field              Max length

Purchase                  6

Week                         2

Year                           4

8 Replies
DavidM
Partner - Creator II
Partner - Creator II

If you want table exactly like you wanted you need to do:

Table:

Load

'Purchase' as Field

Max(Len(Purchase) as MaxLenght

Resident tbl;

concatenate (Table)

Load

'Week' as Field

Max(Len(Week) as MaxLenght

Resident tbl;

concatenate (Table)

Load

'Year' as Field

Max(Len(Year) as MaxLenght

Resident tbl;

 

achitreskyitgroup
Partner - Contributor II
Partner - Contributor II
Author

Hello David, thank you so much for your reply.

I want to do it in a pivot table. There are 68 fields for which I want to find the max len of row.

DavidM
Partner - Creator II
Partner - Creator II

Are all fields in one table?
achitreskyitgroup
Partner - Contributor II
Partner - Contributor II
Author

Yes

DavidM
Partner - Creator II
Partner - Creator II

I think you can do it with usage of system fields $table and $field.

Or you can create a new table, load the names of the fields with FieldName() and then with iteration you could assign the field name to variable and load each time max and join it to one table.

 

achitreskyitgroup
Partner - Contributor II
Partner - Contributor II
Author

I found a qlikview file with this expression. It works fine there but the same expression does not work in any other Qv document

 

-

pick(wildMatch(Only([$Field]),SubField('$(vvv)','|',1),SubField('$(vvv)','|',2),SubField('$(vvv)','|',3))
,max(len($(=SubField('$(vvv)','|',1))))
,max(len($(=SubField('$(vvv)','|',2))))
,max(len($(=SubField('$(vvv)','|',3))))
)

Brett_Bleess
Former Employee
Former Employee

Abhishek, Check out the Governance Dashboard application, that may have what you need, or give you some further ideas on how to go about things.

https://help.qlik.com/en-US/governance-dashboard/Content/What.htm

You can download the actual app from the download site, Choose QlikView product area and then look for the Governance Dashboard in the Product list box there.  Sorry I do not have anything better.

The only other place I could recommend to search would be the Design Blog area:

https://community.qlik.com/t5/Qlik-Design-Blog/bg-p/qlik-design-blog

There are lots of posts out there on how-to, so you may find something there that helps as well.

My post will also kick this back up in the list, so someone else may see things and chime in too.

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Dimension:
$Field

Expression: 
pick(
FieldIndex('$Field', [$Field])
,
$(=concat({1} DISTINCT  'max(len([' & [$Field] & ']))', ',', FieldIndex('$Field', [$Field])))
)

-Rob
http://masterssummit.com
http://qlikviewcookbook.com
http://www.easyqlik.com