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

Create a bar chart based on a condition

I have my data where the important columns are - date_a, date_b, date_c

in a bar chart I need to show the X axis - pass and fail, and Y axis - counts of pass and fail (image pasted below)

logic  - 

1) if date_a < date_b, then consider date_a else date_b ( the date which is considered  say imp_date), after that

2)if date_c - imp_date < 60 then pass else fail

Oero_0-1677686995504.png

Any help will be appreciated, Thanks in advance

 

 

Labels (4)
5 Replies
ogster1974
Partner - Master II
Partner - Master II

First you need to do some work in the script to build up your conditions.  I assume you are counting sokmething so added a simple unique key to the model.

// Sample Data

Tmp:
Load * Inline [
Key, date_a, date_b, date_c
1 , 01/01/2023, 15/01/2023, 31/12/2022
2 , 15/01/2023, 01/01/2023, 31/12/2022
3 , 15/01/2023, 01/01/2023, 31/01/2023
4 , 01/01/2023, 15/01/2023, 31/01/2023
5 , 01/01/2023, 15/01/2023, 31/12/2022
6 , 01/01/2023, 15/01/2023, 31/05/2022
7 , 15/01/2023, 01/01/2023, 31/05/2023
8 , 15/01/2023, 01/01/2023, 31/03/2023
9 , 15/01/2023, 01/01/2023, 31/03/2023
10 , 15/01/2023, 01/01/2023, 01/01/2023
];

// your business logic to get Imp Date, Imp days and Imp result.

NoConcatenate
Data:
Load
*,
If(imp_days<60, 'Pass','Fail') as imp_result
;
Load
*,
date_c - imp_date as imp_days
;
Load
*,
if( date_a < date_b, date_a, date_b) as imp_date
Resident Tmp;

drop table Tmp;

Then apply them easily in the front end.

ogster1974_0-1677690018005.png

 

 

Oero
Contributor III
Contributor III
Author

Hi sir, thanks for the help.
just need to ask, I have imported the data by simple drag and drop,
and what is happening in Tmp?

 

ogster1974
Partner - Master II
Partner - Master II

Tmp is just the data I created to prove the solution would work so replace Tmp with whatever you've called your data table.

The solution I've created requires you to modify the script so go to data load editor once imported and unlock your script so you can add the logic I've provided.

ogster1974_0-1677691371707.png

once added load the data and you can create what you need in the front end chart wise.

Oero
Contributor III
Contributor III
Author

ooh okay sir got it, now its clear, ok let me give it a try (that load script screen shot really helped, thanks).

 

vinieme12
Champion III
Champion III

As below

 

Dimension

=  Aggr( If (  (date_c - rangemin(date_a ,date_b)) <60,'Pass','Fail')  , SomeIDField )

Measure

=Count(Distinct  SomeIDField  )

 

SomeIDField   is a field that identifies each row uniquely

 

 

 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.