Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
subho220
Helper I
Helper I

max function

Hi, I want to take only the value as max only if it is +2 greater than previous value.

example
lets say we have data like
1
2
3
4
 
if max is applied on this column it will give 4
but the requirement is to get 3
 
how can I achieve that?
6 REPLIES 6
amitchandak
Super User
Super User

@subho220 , Try a measure like

 


new value =
var _max = calculate(max(Table[Value]))
return
maxx(filter(Table, Table[Value] <_max),Table[Value])

PhilipTreacy
Super User
Super User

Hi @subho220 

Why is 3 the answer?  3 is not +2 greater than 2?

Phil


If I answered your question please mark my post as the solution.
If my answer helped solve your problem, give it a kudos by clicking on the Thumbs Up.



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


hi ,

So what I actually want is -

 

if you compare all the columns with offset +2 for max 1 compare 2, will be 1 since 2 is not +2 times greater then 1 since 2 didn't take the max value we will still have 1 as the Max 1 compares 3 will be 3 since 3 is +2 times greater then 1 since 3 is the max now next comparison will be done with 3, 3 compare 4 will be 3 since 4 is not +2 greater then 3

 

@PhilipTreacy  @amitchandak 

Hi @subho220 

Try this 

 

 

let
    NumberList = {1,2,3,4},
    
        res = List.Accumulate
            (
                NumberList,

                NumberList{0},
                
                (state, current) => 
                
                    if current > (state + 1) then current else state
                                    
            )
in
    res

 

 

 

or using some data in a column

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlSK1YlWMgKTxmDSRCk2FgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Numbers = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Numbers", Int64.Type}}),
    res = List.Accumulate
            (
                #"Changed Type"[Numbers],

                #"Changed Type"[Numbers]{0},
                
                (state, current) => 
                
                    if current > (state + 1) then current else state
                                    
            )
in
    res

 

Phil 


If I answered your question please mark my post as the solution.
If my answer helped solve your problem, give it a kudos by clicking on the Thumbs Up.



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Can it be done in measure?

Hi, @subho220 

Not sure about the calculation logic.
For the following data ,your requirement is to get 7,right ?

Original Data   Max Result
2   2
3   2
5   5
6   5
4   5
7   7
8   7

 

Best Regards,
Community Support Team _ Eason



Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.