Need help in re-order / sort Bars in Bar Chart in Qliksense - qliksense

I am trying to reorder the Bars in bar chart in qliksense. Below is the order which I have to sort the bars.
NEW
IN_PROGRESS_PL
ASSIGNED
IN_PROGRESS_SPOC
RESOLVED/CLOSED
FBS E2S BACKLOG
CANCELLED
DUPLICATE
But by default the bars are ordered in alphabetical order or by the numbers, I have tried the below solution, but it still didn't rearranged the bars.
Default order :
Match('NEW','IN_PROGRESS_PL','ASSIGNED','IN_PROGRESS_SPOC','RESOLVED/CLOSED','FBS E2S BACKLOG' , 'CANCELLED','DUPLICATE' )
Can someone please help me to fix this issue.

The first parameter in Match is the targeted field.
If we have data like:
RawData:
Load * inline [
Stage , IdeasCount
ASSIGNED , 63
CANCELLED , 11
INTERNAL_123, 2
IN_PROGRESS1, 20
IN_PROGRESS2, 47
];
Then the sorting expression will be:
=match(Stage, 'IN_PROGRESS1', 'ASSIGNED', 'IN_PROGRESS2', 'INTERNAL_123', 'CANCELLED')
The sorting properties:
And the result chart will have the correct sorting:
P.S. (1)
Have to mention that if the value is not found in the Match function then the function will return null and thus the corresponding bar will be pushed in the front. In this case you can wrap the match in if statement and if no matching value is found then assign some large number:
= if( match(Field, 'value1', 'value2' ...) > 0,
match(Field, 'value1', 'value2' ...),
1000
)
P.S. (2)
In your case you can also use Dual function to create "default" sort order for a specific field.
If we change the script to:
RawData:
Load
Dual(Stage, OrderId) as Stage,
IdeasCount
;
Load * inline [
Stage , IdeasCount, OrderId
ASSIGNED , 63 , 2
CANCELLED , 11 , 5
INTERNAL_123, 2 , 4
IN_PROGRESS1, 20 , 1
IN_PROGRESS2, 47 , 3
]
;
The result table will look the same - with two fields only Stage and IdeasCount. But in the background each value of Stage field will have and number representation (based on the initial OrderId field). And as a side effect of that the auto sorting option will sort the field data by its internal number representation and the chart will "sort itself" correctly

Related

Using Postgresql, count consecutive numbers in a table, which has length of more than 5

Telephone_number
111111111
1111143452
000000000
888888888
5554038291
1111392012
9999999999
2324666666
So from the above, I want to have only those records that have the same digit repeated more than 5 times.
The output count should be 5.
You can a regular expression with a repeated back reference.
with test (telephone_number) as
( values ('111111111')
, ('1111143452')
, ('000000000')
, ('888888888')
, ('5554038291')
, ('1111392012')
, ('9999999999')
, ('2324666666')
)
select telephone_number
from test
where telephone_number ~ '(\d)\1{5,}';
This does depend on how the columns are defined, as numeric or as text. If numeric definition then you need to play around in converting to text for using a regular expression. See fiddle.

Filter portal for most recently created record by group

I have a portal on my "Clients" table. The related table contains the results of surveys that are updated over time. For each combination of client and category (a field in the related table), I only want the portal to display the most recently collected row.
Here is a link to a trivial example that illustrates the issue I'm trying to address. I have two tables in this example (Related on ClientID):
Clients
Table 1 Get Summary Method
The Table 1 Get Summary Method table looks like this:
Where:
MaxDate is a summary field = Maximum of Date
MaxDateGroup is a calculated field = GetSummary ( MaxDate ;
ClientIDCategory )
ShowInPortal = If ( Date = MaxDateGroup ; 1 ; 0 )
The table is sorted on ClientIDCategory
Issue 1 that I'm stumped on: .
ShowInPortal should equal 1 in row 3 (PKTable01 = 5), row 4 (PKTable01 = 6), and row 6 (PKTable01 = 4) in the table above. I'm not sure why FM is interpreting 1Red and 1Blue as the same category, or perhaps I'm just misunderstanding what the GetSummary function does.
The Clients table looks like this:
Where:
The portal records are sorted on ClientIDCategory
Issue 2 that I'm stumped on:
I only want rows with a ShowInPortal value equal to 1 should appear in the portal. I tried creating a portal filter with the following formula: Table 1 Get Summary Method::ShowInPortal = 1. However, using that filter removes all row from the portal.
Any help is greatly appreciated.
One solution is to use ExecuteSQL to grab the Max Date. This removes the need for Summary functions and sorts, and works as expected. Propose to return it as number to avoid any issues with date formats.
GetAsTimestamp (
ExecuteSQL (
"SELECT DISTINCT COALESCE(MaxDate,'')
FROM Survey
WHERE ClientIDCategory = ? "
; "" ; "";ClientIDCategory )
)
Also, you need to change the ShowInPortal field to an unstored calc field with:
If ( GetAsNumber(Date) = MaxDateGroupSQL ; 1 ; 0 )
Then filter the portal on this field.
I can send you the sample file if you want.

Min value with GROUP BY in Power BI Desktop

id datetime new_column datetime_rankx
1 12.01.2015 18:10:10 12.01.2015 18:10:10 1
2 03.12.2014 14:44:57 03.12.2014 14:44:57 1
2 21.11.2015 11:11:11 03.12.2014 14:44:57 2
3 01.01.2011 12:12:12 01.01.2011 12:12:12 1
3 02.02.2012 13:13:13 01.01.2011 12:12:12 2
3 03.03.2013 14:14:14 01.01.2011 12:12:12 3
I want to make new column, which will have minimum datetime value for each row in group by id.
How could I do it in Power BI desktop using DAX query?
Use this expression:
NewColumn =
CALCULATE(
MIN(
Table[datetime]),
FILTER(Table,Table[id]=EARLIER(Table[id])
)
)
In Power BI using a table with your data it will produce this:
UPDATE: Explanation and EARLIER function usage.
Basically, EARLIER function will give you access to values of different row context.
When you use CALCULATE function it creates a row context of the whole table, theoretically it iterates over every table row. The same happens when you use FILTER function it will iterate on the whole table and evaluate every row against the filter condition.
So far we have two row contexts, the row context created by CALCULATE and the row context created by FILTER. Note FILTER use the EARLIER to get access to the CALCULATE's row context. Having said that, in our case for every row in the outer (CALCULATE's row context) the FILTER returns a set of rows that correspond to the current id in the outer context.
If you have a programming background it could give you some sense. It is similar to a nested loop.
Hope this Python code points the main idea behind this:
outer_context = ['row1','row2','row3','row4']
inner_context = ['row1','row2','row3','row4']
for outer_row in outer_context:
for inner_row in inner_context:
if inner_row == outer_row: #this line is what the FILTER and EARLIER do
#Calculate the min datetime using the filtered rows
...
...
UPDATE 2: Adding a ranking column.
To get the desired rank you can use this expression:
RankColumn =
RANKX(
CALCULATETABLE(Table,ALLEXCEPT(Table,Table[id]))
,Table[datetime]
,Hoja1[datetime]
,1
)
This is the table with the rank column:
Let me know if this helps.

Finding a value in a multi select list parameter in report?

I have a multi select input parameter for a report.
We know how to find whether a values is present in that parameter or not by using
$X{IN, colName, paramName}
the above expression in WHERE condition clause.
That is working fine.
But how will we find whether a variable ( let say having value 3 ) is present in parameter ( same multi select list let say [ 1, 2 ,3, 5] ) or not.
By validating the above condition i want to display something in report's static text field.

Calculate value based on existence of records matching given criteria - FileMaker Pro 13

How can I write a calculation field in a table that outputs '1' if there are other (related) records in the same table that meet a given set of criteria and '0' otherwise?
Here's my problem explained in more detail:
I have a table containing 'students' and another containing 'exam results'. The 'exam results' table looks like this:
StudentID SubjectID Level Result
3234 1 2 A-
3234 2 4 B+
4739 1 4 C+
A student can only pass a Level 4 exam in subject 2 if they have also passed a Level 2 exam in subject 1 with a B+ or higher. I want to define a field in the 'students' table that contains a '1' if there exists an exam result belonging to the right student that meets these criteria and a '0' otherwise.
What would be the best way to do this?
Let us take an example of a Results table where the results are also calculated as a numeric value, e.g.
StudentID SubjectID Level Result cResultNum
3234 1 2 A- 95
3234 2 4 B+ 85
4739 1 4 C+ 75
and an Exams table with the following fields (among others):
RequiredSubjectID
RequiredLevel
RequiredResultNum
Given these, you can construct a relationship between Exams and (another occurrence of) Results as:
Exams::RequiredSubjectID = Results 2::SubjectID
AND
Exams::RequiredLevel = Results 2::Level
AND
Exams::RequiredResultNum ≤ Results 2::cResultNum
This allows each exam record to calculate a list of students that are eligible to take that exam as =
List ( Results 2::StudentID )
I want to define a field in the 'students' table that contains a '1'
if there exists an exam result belonging to the right student that
meets these criteria and a '0' otherwise.
This request is unclear, because there are many exams a student may want to take, and a field in the Students table can calculate only one result.
You need to do a self-join in the table for the field you want to check, for example:
Exam::Level = Exam2::Level
Exam::Student = Exam2::Student
And for the "was passed" criteria I think you could do an "If" on the calculation like this:
If ( Last(Exam2::Result) = "D" and ...(all the pass values) ; 1 ; 0 )
Edit:
It could be just with the not pass value hehe I miss that it will be like this:
If ( Last(Exam2::Result) = "F" ; 0 ; 1 )
I hope this helps you.