BusinessObjects Board

Max Date for certain value of other column

Hi, hopefully this board is still active and can help me.

image

So what I am looking for is the correct webi formula that will give me the max date where movement type is 202.

MaxDate is no problem but this now gives me 6/30/22.
But I want the max date for MvT 202 so that would be 5/31/22

Tried several variants however a simple :
=Max([Posting Date]) Where ([Movement Type] = “202”) would work.
But that still gives me multi values.
Yes 202 is not unique in the list but that is why I want the max date for MvT 202.

Note there are multiple Materials also. So maybe that is causing the problem.

1 Like

Hi

I’d try
=Max([Posting Date) in ([Movement Type])
Then it will return the maximum date for each movement type. If you only want the max date for 202 and no other movement type, you could then do something like
=If([Movement Type]=202; Max([Posting Date)In([Movement Type]);"")
but I may have misunderstood what you need there!

1 Like

Thanks @slinkywhite , think you understood correct.
But material - key is also in play.

Your method gives me a lot of blanks but for every material there should be at least 1 posting date for movement type 202.

I am combining sources here.
The posting date and movement type is in a different source but is connected by the material -key.

If you need the max date split by the Material - key too, then try
=Max([Posting Date) in ([Movement Type];[Material - Key])
or
=If([Movement Type]=202; Max([Posting Date)In([Movement Type];[Material - Key]);"")

1 Like

Unfortunately no luck @slinkywhite
The first line works fine, it gives me the max date.
But still the part to give me the max date belonging to movement type 202 is not working.
For your reference 202 is a text field so I need to use “202”.

Maybe some screens of the 2 sources could shed some light:

So first source is (UAL) and Addendum Part Number is the key that ties to Material - key in the second source.

As you see in the query filter.
And also I merged these 2 fields to connect these 2 universes together.
So this field is the main key in my report:
image

Posting Date Addendum is now the normal max date. It works.
But I need to get the max date of Movement type (that you see in the second universe) 202.
Because for the yellow line the correct date is 5/31/22 and not 6/30/22

if only [Movement Type] is your key to get the max. date, you have to remove [Material - Key] from the context of your formula and calculate this within another variable

Thanks @N8AKTIV
But I am afraid I don’t understand what you mean.
About what formula are we talking?
And what should I calculate with another variable?

Based on this first table, what do you want your resulting display to be?

If there just one row, i.e. filter out the others, or do you want the result to be another column in the same block?

This will determine what the answer is because the calculation context may vary depending upon what else is in the block.

@MarkP well the table I use is only an example to show that there are multiple dates for multiple Movement Types.
I want for every line op material/addendum part the max date belonging to a certain movement type I set in the formule (now talking about 202 but another time I will make a formule for 201 etc.)

The end result then looks like:


As you see here in yellow the max date is 6/30/22 for material APL2114536.
But this is the max date for all dates for this material.
The one I am looking for is 5/31/22 which is the max date for movement type 202 of material APL2114536.

In that case, I think you weren’t far off with this:

Either of these should work:
=Max(If [Movement Type] = “202” Then [Posting Date])

=Max([Posting Date] Where ([Movement Type] = “202”))

As you’ve taken the Movement Type object out of the block, you need to evaluate it first, otherwise you’ll get your multivalues.

Thanks @MarkP ,
However I am getting a context error for both solutions:

Note I have 2 posting dates in seperate universes. To explain better I justed named it Posting Date.
This is the code I used. Maybe that specific posting date is causing the problem?
=Max([InvAddendum].[Posting Date] Where ([Movement Type]=“202”))

try with variable of type „detail“ and set the dependency to the join-field (material-key?)
or
try with ForceMerge()

Ah, okay. So we’re dealing with differences in granularity between queries that you’re trying to put together. Be very careful - you won’t get a Posting Date to match with a Movement Type if they’re from different queries and aren’t in both query. Is it possible to bring Addendum Part into the second query - that way you’re getting the Posting Date at the part level, which would make sense to Webi.

There are indeed multiple queries.

The main query has these fields:
image

Is is not very complex but based on this we are pulling data from other queries in for the end report.

So every material has an addendum part.
Then the second query looks like:
image

I linked the output of that query to the first (main) query.
The addendum part numbers show in that second query as material.
So field material in this query will be only filled with the addendum part numbers from query 1.
(also plant is linked but that is always the same)

You see in the second query there is posting date and movement type.

I used a merg like:
image
There is a link with a 3rd query in there but for this field that I am trying to calculate it is not in scope.

The end result we want to look like this:
image

So here the first date now it the max posting date for a addendum part.
In 90% of the cases this will be ok but to make it a 100% we want to look for the max date of a certain movement type.

Not sure what you mean with bring addendum part to the 2nd query.

The end report we want is a combination from data out of all queries.

I suggested bringing date in because you can’t use dimensions from two queries if they aren’t merged.

Simply making them a detail won’t work if they aren’t a one-to-one relationship with the owning dimension as that’s not how details work.

As you have Movement Type/Posting Date from one query and Addendum Part from another and Webi doesn’t know their relationship (other than having the same owning plant), they will have a different usage, i.e. context, hence the #CONTEXT error that you get.
Which is why I was wondering if it is possible to get all three in the same query. :slight_smile:

Hmm I have from Q2:
Material - key -Posting Date
- Movement Type

Q1:
Addendum Part Number

Then merging Material - key and Addendum Part Number into Addendum Part.

Should it then not be possible to get to movement type and posting date?
Actually I already got the posting date (its Posting Date Addendum).

But I guess then getting the posting date for a certain movement type is too complex for webi.

If your queries are merged at a level where you only have one addendum part per movement type, you might be ok. An alternative that might work:
Create a max(table.postingdate) measure in your universe. Use this in a query at the right level of granularity so that you’ll only get one row per part and movement type. Obviously without knowing the database it’s not a definite but it might be possible.

At the moment you’re asking the equivalent of maximum number of doors on a motorbike when you sell all sorts of vehicles and it can’t handle the small out of context part of your query.

Well @MarkP @N8AKTIV @slinkywhite thanks all for your inputs.

The problem has been solved now with:
=Max([InvAddendum].[Posting Date] In ([Addendum Part]) Where ([Movement Type]=“201”))

(yes 201…change of insight on the users part :wink: But does not change anything to the logic)

So we were close :smiley:

1 Like

Excellent! Glad it got sorted!

Good. As I said at the start, without knowing your data, we were on best guesses rather than anything that solid.