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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Anonymous
Not applicable

DAX: retrieve the minimum value among the values above another

Hello,

 

I need help from the community

 

I need to find a solution in DAX

 

Let me explain:

I have several columns: Item, QuantityA and QuantityB. (QuantityB is from a merge with another table in Power Query)

I would like to keep among the values of QuantityB the smallest value among those which are superior to the values of QuantityA. But if no value of QuantityB is greater than QuantityA then I have to write 0.

 

Example : 

Origine :

Articles

QuantitéA

QuantitéB

A

25

12

A

25

50

A

25

80

B

45

25

B

45

0

C

80

100

C

80

20

 

Desired résult :

Articles

QuantitéA

QuantitéB

A

25

50

B

45

0

C

80

100

 

I already have a solution in Power Query but the problem is that on all my data, it requires too many resources to the computer and some employees can not update the data without the computer crashes.

 

Thank you in advance for your help,
Good day to all,

Sincerely,

FDANIEL

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

It is for creating a new table.

 

Jihwan_Kim_0-1666191786228.png

 

 

New Table = 
ADDCOLUMNS (
    SUMMARIZE ( Data, Data[Articles], Data[QuantityA] ),
    "@QuantityB",
        SUMX (
            FILTER (
                GROUPBY (
                    FILTER (
                        ADDCOLUMNS ( Data, "@flag", IF ( Data[QuantityA] < Data[QuantityB], 1 ) ),
                        [@flag] = 1
                    ),
                    Data[Articles],
                    "@MinB", MINX ( CURRENTGROUP (), Data[QuantityB] )
                ),
                Data[Articles] = EARLIER ( Data[Articles] )
            ),
            [@MinB]
        ) + 0
)

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

It is for creating a new table.

 

Jihwan_Kim_0-1666191786228.png

 

 

New Table = 
ADDCOLUMNS (
    SUMMARIZE ( Data, Data[Articles], Data[QuantityA] ),
    "@QuantityB",
        SUMX (
            FILTER (
                GROUPBY (
                    FILTER (
                        ADDCOLUMNS ( Data, "@flag", IF ( Data[QuantityA] < Data[QuantityB], 1 ) ),
                        [@flag] = 1
                    ),
                    Data[Articles],
                    "@MinB", MINX ( CURRENTGROUP (), Data[QuantityB] )
                ),
                Data[Articles] = EARLIER ( Data[Articles] )
            ),
            [@MinB]
        ) + 0
)

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
Anonymous
Not applicable

Hello,

I have applied your solution and it works perfectly.

Thank you very much for your help.

 

Sincerely,

FDANIEL

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.