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
mhsk
Helper II
Helper II

Obtain single value from column with max values into a new column

Easy question:

 

how to get just a single value from sumQty_by_item column?

 

locationpartqtysum_qty_by_itemdateexpected result
1111106001.05.201960
2111206001.05.20190
3111306001.05.20190
12225901.05.20199
22221901.05.20190
32223901.05.20190
111152502.05.201925
211162502.05.20190
311172502.05.20190
411172502.05.20190

 

is it even possible with dax? i need it in new column as im using it in chart/as slicer etc.

1 ACCEPTED SOLUTION

Hi @mhsk 

I would suggest you to add an index column in query editor.Then create the column as below:

Column =
VAR pre_sum =
    CALCULATE (
        MAX ( 'Table'[sum] ),
        FILTER ( 'Table', 'Table'[Index] = EARLIER ( 'Table'[Index] ) - 1 )
    )
RETURN
    IF (
        pre_sum <> 'Table'[sum],
        CALCULATE ( MAX ( 'Table'[sum] ), ALLEXCEPT ( 'Table', 'Table'[sum] ) ),
        0
    )

1.png

Regards,

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
v-cherch-msft
Employee
Employee

Hi @mhsk 

You may try below dax.

Column =
IF (
    [location] = 1,
    CALCULATE (
        MAX ( [sum_qty_by_item] ),
        ALLEXCEPT ( 'Table', 'Table'[sum_qty_by_item] )
    ),
    0
)

1.png

Regards,

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

thanks for a prompt reply, the thing is I don't want to connect it anyhow to location imagine my table looks:

 

part sumexpected result
1115050
111500
111500
2226060
222600
222600
33311
33310
33310
4441010
444100
444100

Hi @mhsk 

I would suggest you to add an index column in query editor.Then create the column as below:

Column =
VAR pre_sum =
    CALCULATE (
        MAX ( 'Table'[sum] ),
        FILTER ( 'Table', 'Table'[Index] = EARLIER ( 'Table'[Index] ) - 1 )
    )
RETURN
    IF (
        pre_sum <> 'Table'[sum],
        CALCULATE ( MAX ( 'Table'[sum] ), ALLEXCEPT ( 'Table', 'Table'[sum] ) ),
        0
    )

1.png

Regards,

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

ok this works while parts are always represented in multiple rows, but there are also cases where part can have just one row (no index-1 possible) - like part 555 below, could you have a look ?

part sumexpected result
1115050
111500
111500
2226060
222600
222600
33311
33310
33310
4441010
444100
444100
5551515

Hi @mhsk 

The above workaround could work for your scenario.

1.png

Regards,

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.