How to let user select columns to be displayed in table on Qliksense? - qlikview

I have a table with a large number of columns so I would like to have a filterpane/listbox with all the dimensions and measures allowing the user to select the columns they would like to see in the table.
My table looks like this where the columns are displayed based on the selection:
So something like this:
I tried to do it using this solution but it does not appear to do anything. Can someone tell me where I'm going wrong?/How can I do this?
Here is my script in the load editor where I create the table for the selection:
Selection:
load * inline [
Dimension
Category
Revenue
Year
ProductName
ProductID
Date
];
Here is my condition for each of the columns in the table, using column ProductID as an example:
=SubStringCount(Concat(Measure),1), ProductID)

You can try this:
Set vShowCollumn = Not IsNull(GetFieldSelections($1)) and WildMatch(Concat($2,','),'*$3*');
I_DIMENSIONS:
Load
*
InLine [
_Dimension , _CodDimension
Product , 001
Shop , 002
];
and in the product you choose de number, respondind with your inline, for example:
$(vShowcollumn(_Dimension,_CodDimension,001))
so, when it gonna show only when user click in the dimension.

Related

Qlik - Building a dynamic view

I have a SQL query that creates a table, and every month 2 new columns will be added for that table related to the current month.
I have tried without success to set up a flat table (visual) in Qlik that will automatically expand every month to include these table. Is there a way to do this, and i so please point me in the right direction.
You can have a look at CrossTable prefix.
This prefix allows a wide table to be converted to a long table.
So if we have data like this:
After running the following script:
CrossTable:
CrossTable(Month, Sales)
LOAD Item,
[2022-10],
[2022-11],
[2022-12],
[2023-01],
[2023-02],
[2023-03],
[2023-04]
FROM
[C:\Users\User1\Documents\SO_75447715.xlsx]
(ooxml, embedded labels, table is Sheet1);
The final data will looks like below. As you can see there are only 3 columns. All xls month columns (after Item) are now collapsed under one field - Month and all the values are collapsed under Sales column.
Having the data in this format then allows creating "normal" charts with adding Month column as dimension and use sum(Sales) as an expression.
P.S. If you dont want to manage the new columns being added then the script can be:
CrossTable(Month, Sales)
LOAD
Item,
*
FROM
...

Create a "products you may be interested in" algorithm in SQL?

i have a problem which im not sure how to approach.
I have a simple database where i store products , users , and purchases of products by users.
Each product has a name , a category and a price.
My goal is the following :
I want to display a list of 5 items that are suggested as "You might be interested in" to the user.The main problem is that i don't just want to search LIKE %..% for the name , but i also want to take into account the types of products the user usually buys , the price range he usually buys at , and giving priority to products being bought more often.
Is such an algorithm realistic? I can think of some metrics , like grouping all categories into semantically "similar" buckets and calculating distance from that , but im not sure how i should rank them when there is multiple criteria.
Maybe i should give each criteria an importance factor and have the result be a multiplication of the distance * the factor?
What you could do is create 2 additional fields for each product in your database. In the first field called Type for example you could say "RC" and in the second field called similar you could say, "RC, Radio, Electronics, Remote, Model" Then in your query in SQL later on you can tell it to select products that match up between type and similar. This provides a system that doesn't just rely on the product name, as these can be deceiving. It would be still using the LIKE command, but it would be far more accurate as it's pre-defined by you as to what other products are similar to this one.
Depending on the size of your database already, I believe this to be the simplest option.
I was using this on MySql for some weighted search :
SELECT *,
IF(
`libelle` LIKE :startSearch, 30,
IF(`libelle` LIKE :fullSearch, 20, 0)
)
+ IF(
`description` LIKE :startSearch, 10,
IF(`description` LIKE :fullSearch, 5, 0)
)
+ IF(
`keyword` LIKE :fullSearch, 1, 0
)
AS `weight`
FROM `t`
WHERE (
-- at least 1 match
`libelle` LIKE :fullSearch
OR `description` LIKE :fullSearch
OR `keyword` LIKE :fullSearch
)
ORDER BY
`weight` DESC
/*
'fullSearch'=>'%'.str_replace(' ', '_', trim($search)).'%',
'startSearch'=>str_replace(' ', '_', trim($search)).'%',
*/

How to get an group data from sql?

Can anyone help me create chart like the one below? I'm using CFDB on wordpres. It is a simple form inputs counter.
I've figured out something like this:
SELECT month(FROM_UNIXTIME(`submit_time`)) as miesiac,
year(FROM_UNIXTIME(`submit_time`)) as rok,
`form_name`, `field_name`, `field_value`, `field_order`, `file`
FROM `wp_cf7dbplugin_submits`
WHERE year(FROM_UNIXTIME(`submit_time`)) = 2016
I would like to get final result like in the attachment.
Now I get something like this one:
enter image description here
In order to generate the data needed for a chart like the one in your example, you need to return the number of form submissions for each month and form type.
SELECT COUNT(sub.form_name) as total, sub.form_name, sub.miesiac
FROM (
SELECT DISTINCT `submit_time`, month(FROM_UNIXTIME(`submit_time`)) as miesiac,
`form_name`
FROM `wp_cf7dbplugin_submits`
WHERE year(FROM_UNIXTIME(`submit_time`)) = 2016 ) sub
GROUP BY sub.form_name, sub.miesiac
The sub-query identifies the distinct submissions (since each submission has multiple rows) and the main query counts the number of submissions for each form type per month. There's no need to include the year because it's already included in the WHERE statement.

Conditional summing in FileMaker Pro 14

I want to know how do you get conditional sums on FM 14, because I can´t find anything.
I have X number of records in a layout. Each record has Price, Name and Month. I want to create another layout in which I will have a table with the months arranged horizontally and Name arranged Vertically. Like this:
January February March April .... .... .... December
Name 1 (calc)
Name 2 (calc)
Name 3 (calc)
....
....
....
Name X
(calc) = Calculation
I want to sum every price on each record that has the Name and Month specified in each calculation.
I can´t find the way to do it and it´s driving me crazy.
Thanks
Create 12 calculation fields with formula:
If( myTable::Month = 'January'; myTable::Price ; "" )
(repeat for every month)
Create a list layout based on the same table, with header and footer
Add sub-summary when sorted by Name
Add to sub-summary Name field
Create a summary fields for every earlier created calculation fields based on Sum()
Add these summary fields to sub-summary layout part
Delete Body layout part
Sort records by Name
Filemaker is not very good at cross-tab reports, Still, here's one way to look at it:
Define a calculation field cSplitByMonth (result is Number, Number of repetitions: 12) =
Let ( [
monthNames = "January¶February¶March¶April¶May¶June¶July¶August¶September¶October¶November¶December" ;
monthName = GetValue ( monthNames ; Get ( CalculationRepetitionNumber ) )
] ;
If ( Extend ( Month ) = monthName ; Extend ( Price ) )
)
Define a summary field as Total of cSplitByMonth, summarize repetitions individually.
Create a layout with a sub-summary part (when sorted by name) and no body part. Place the Name field and the summary field (with all its 12 repetitions, oriented horizontally) in this part.
Sort the records by Name.
Another approach can be seen here: http://fmforums.com/topic/71836-getting-more-out-of-filtered-portals-in-version-11/#comment-339728

Products with only one available colour in stock - SQL query

I have a table that lists thousands of products. A product can be either Standard (123450.000.000), one colour (123456.BLA.000), one size (123456.000.LAR) or both colour and size (123456.BLA.LAR).
A product can have multiple colours (123456.BLA.000, 123456.YEL.OOO etc etc). I am trying to do a query that brings back a product that has multiple colours but only one colour in stock i.e. ProductQTY = 1 and the remaining colours are out of stock.
All I have been able to come up with is the query below but this just brings back all 'variant' products that have 1 in stock. What do I have to add or change to make it bring back results whereby a product has different colours but only ONE of those colours are in stock and the remaining are out of stock? Do I need to do a UNION?
select *
from Product
where productcode NOT LIKE ('%000.000')
AND ProductQTY = '1'
First off, that's a terrible structure. Store color and size information in separate tables, don't make them part of one massive variable.
Second, you want to do a query that selects Product IDs (1-6, looks like) that have a count > 1 with color present and the sum of their quantities is 1 exactly (according to your question - if that one record could have a qty>1 and still be okay, this is a little more complicated).
select * from product where substr(product,1,6) in (
select substr(product,1,6) from product
where not (product like '%.000.%')
group by 1
having count(1) > 1
and sum(ProductQTY)=1
)
The question would be much easier if you would split up the properties in different columns. But you could do that in a query aswell:
select code from
(select substring(productcode,-3) as size,
substring(productcode,-7,3) as colour,
substring(productcode,0,len(prodcutcode)-7) as code
from product) t
group by code
having sum(productQTY) = 1
//or count(*) = 1 to get all unique ones