Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
BasC
Contributor II
Contributor II

Getting value A based of max of values B, if value C is...

This is the way the data is built up. All irrelevant data is blurred.

Data model viewer - 3 tablesData model viewer - 3 tables

Each [ritdossier] has multiple [dossier] values. Each [dossier] has multple [T&T_kode_order] and [tracdatum_order] and [tractijd_order] values.

But each [dossier] only has 1 [rijduur] value.

What I want is the value [rijduur] , of the Max([tractijd_order]) of that [ritdossier], if the [T&T_kode_order] = 'GETEKEND' and [tracdatum_order] = [KDatum] .

This formula works and gives me the right value for [tractijd_order]:

 

max(
      if(
      		tracdatum_order = KDatum and [T&T_kode_order]='GETEKEND',
          	tractijd_order
      )
)

 

But I just can't figure out how to connect this to [rijduur].

I've been stuck with this one for ages, despite reading here a lot and trying out a bunch of things. Hopefully I've explained it somewhat understandably. Thanks very much in advance for you help.

 

 

 

 

 

 

1 Solution

Accepted Solutions
Kushal_Chawda

@BasC  try with distinct if still does not work then suggest you to create mockup data with expected output

=Firstsortedvalue
( distinct 
[rijduur] 
,
-if
   (
    tracdatum_order = KDatum and [T&T_kode_order]='GETEKEND',
    tractijd_order
   )
)

 

View solution in original post

4 Replies
Kushal_Chawda

@BasC  try below

=Firstsortedvalue
(
[rijduur] 
,
-if
   (
    tracdatum_order = KDatum and [T&T_kode_order]='GETEKEND',
    tractijd_order
   )
)
BasC
Contributor II
Contributor II
Author

@Kushal_ChawdaThanks for the quick reply, I appreciate it! I think I might have tried this expression at some point. But it doesn't work. I'm getting Null values unfortunately.

Kushal_Chawda

@BasC  try with distinct if still does not work then suggest you to create mockup data with expected output

=Firstsortedvalue
( distinct 
[rijduur] 
,
-if
   (
    tracdatum_order = KDatum and [T&T_kode_order]='GETEKEND',
    tractijd_order
   )
)

 

BasC
Contributor II
Contributor II
Author

Ah yes, that seems to have worked! Thank you so much!