20 Replies Latest reply: Mar 27, 2015 10:57 AM by Michael Solomovich

# Calculate the maximum value

Hi everyone,

I have a dimension and I want to calculate the maxium value from my data. In the example I saw it says it should be calculated by the following expression:

\$(=max(aggr(sum(sales), OrderDate)))

I already tried but I didnt get any successful result. Can someone help me out?

How can I calculate the maximum in the expression where the data has different dimension but I want to calculate the maximum value from all my data. I read it can be calculated using the expression \$(=)

Any thoughts?

• ###### Re: Calculate the maximum value

You need to use rank-function to find out maxium value. Expression is something like this:

=date(max(aggr(if(Rank(Sum(sales))=1, OrderDate),OrderDate)))

• ###### Re: Calculate the maximum value

It isn't working. You put the date, but I want the value, but even though I remove the date it doesnt work.

• ###### Re: Calculate the maximum value

Are you using it inside of set analysis? Then expression is like this

YourDateField={"(=max(aggr(if(Rank(Sum(sales))=1, OrderDate),OrderDate)))"}

• ###### Re: Calculate the maximum value

Try this expr

=max(aggr(sum(sales), OrderDate))

• ###### Re: Calculate the maximum value

It doesnt work.

• ###### Re: Calculate the maximum value

Can you post sample data.

What are the dimensions used in the chart?

• ###### Re: Calculate the maximum value

Pedro,

You have to explain better and/or to upload an example.  The expression you show is returning maximum daily sales (by order date).  Is it what you need?  You say "didn't get any successful result" but you have to tell what the expectation is.
And "it doesn't work" isn't an explanation either

Thanks,
Michael

• ###### Re: Calculate the maximum value

Try this:

=FirstSortedValue(sales,-OrderDate)

• ###### Re: Calculate the maximum value

Hi,

You can try this expressions.

\$(=max(aggr(sum({<OrderDate= >} sales ))))

OR

\$(=max(aggr(sum({<OrderDate= >} sales ),any one dimension field)))

• ###### Re: Calculate the maximum value

I know ,"it doesnt work is not an answear" but If I could elaborate more I would. Nevertheless, I updated my qvw file. I want to select the maximum value on all cells.

• ###### Re: Calculate the maximum value

I hope it helps, see text box in the attached.

• ###### Re: Calculate the maximum value

Can you give me the code? I dont have a lincese on wlikview. At least for now.

• ###### Re: Calculate the maximum value

I added a text box with this:

=max(aggr(sum(Numbers), Weekday,Month))

It returns the largest value in the table: 228,22917519802

• ###### Re: Calculate the maximum value

But how can I put that value inside of the table. Do you know how can I accomplish that?

• ###### Re: Calculate the maximum value

Too bad you can't open the file...  Well, first change your expression in the table to this:

if(secondarydimensionality()=1, sum(Numbers), max(aggr(sum(Numbers), Weekday,Month)))

That means you'll have different expressions for regular columns and for total, depending on dimensionality.  Next, on Presentation tab, select Weekday, check "Show Partial Sum", and label for total change to "Max" or something like that.

• ###### Re: Calculate the maximum value

BTW, if you have multiple months, each month will have its own row, and you need max value per row, not global - remove month from the aggr.  It will be:

if(secondarydimensionality()=1, sum(Numbers), max(aggr(sum(Numbers), Weekday)))

• ###### Re: Calculate the maximum value

Hi Pedro,

you can try with these two ways:

FIRSTSORTEDVALUE (OrderDate, – aggr(sum(Sale)) )

or

=Max ( aggr ( sum ( Sale ),OrderDate ) )

• ###### Re: Calculate the maximum value

The first solution doesnt work.

The secound gives the wrong output.

• ###### Re: Calculate the maximum value

Try with Pedro

FIRSTSORTEDVALUE (OrderDate, – aggr(sum(Sale)), OrderDate )

• ###### Re: Calculate the maximum value

There is something wrong with that expression.