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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
_ajinkyaj
Frequent Visitor

Need Help: Find the minimum and maximum of Net Price Per Unit for selected period

I want to calculate the variance of Net Price Per Unit over the selected period from (YTD, 1Y, 2Y); 

 

Month-Year/Product NameShip To NameJan-2024Feb-2024Apr-2024
Product AST 1 $58 $54.92
Product AST 2$54.92$54.92 
Product BST 4$56.70  $59.25
Product BST 5$56.70  
Product CST 4$57.70$57.70 $60

 

above table is shown in matrix visual;
want Product Wise Min and Max for example: For Product A : we have 2 Ship To's 6 cell values (contains 2 blanks) Min $54.92 and Max is $ 58.
same goes for Product B: $56.70 and $59.25 and for Product C we have 3 values so $57.70 and $60.

I am able to find Globle min and Max using below dax

 

 

 

 

 

Min or Max Product-ST = 
    var valueDisplayed = 
        CALCULATETABLE(
            ADDCOLUMNS(
                SUMMARIZE(Table 1, Table 2[Product Name], Table 3[Ship To Name], Date[Month-Year]),
                "@Net Price Per Unit", [Selected Period Net Price Per Unit]),
                ALLSELECTED()
        )
    var min_value = 
        MAXX(
        valueDisplayed,
        [@Net Price Per Unit]
        )
    
RETURN
    IF(
        NOT(ISBLANK([Selected Period Net Price Per Unit])), min_value)

 

 

 

 

 

 

However, I want productwise Min and Max so I am struggling to find out the solution.

6 REPLIES 6
VahidDM
Super User
Super User

Hi @_ajinkyaj 

 

Try using ALLEXCEPT to preserve the product context while removing other filters. For example, for the minimum price per product:

 

Min NPPU Per Product =
CALCULATE(
    MINX(
        ADDCOLUMNS(
            SUMMARIZE('FactTable', 'Product'[Product Name], 'ShipTo'[Ship To Name], 'Date'[Month-Year]),
            "@NPPU", [Selected Period Net Price Per Unit]
        ),
        [@NPPU]
    ),
    ALLEXCEPT('Product', 'Product'[Product Name]),
    ALLSELECTED()
)

This ensures the measure returns the minimum Net Price Per Unit within the current product's context, ignoring other filters. Do a similar measure for the maximum value by replacing MINX with MAXX.

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.

Appreciate your Kudos!! 

 

LinkedIn|Twitter|Blog |YouTube 

 

@VahidDM ,
Thanks for replying, However, the dax you mentioned did not behave what I was expecting. It does not even return the global min of that matrix. 
Untitled design.png

_ajinkyaj
Frequent Visitor

@lbendlin , @VahidDM I want to calculate the variance of Net Price Per Unit for each product. For a selected period, there could be no number of STs(Ship To) who have sold that product. I want to see; is there variation in the Net Price Per Unit over those many STs?
As I mentioned, I am able to calculate globle min and max over all the Products and Ship To's within that period using above mentioned DAX like in case of Min below I am getting 

Month-Year/Product NameShip To NameJan-2024Feb-2024Apr-2024
Product AST 1$54.92 $54.92
Product AST 2$54.92$54.92 
Product BST 4$54.92 $54.92
Product BST 5$54.92  
Product CST 4$54.92$54.92$54.92

.
However, I want it Min as

Month-Year/Product NameShip To NameJan-2024Feb-2024Apr-2024
Product AST 1$54.92 $54.92
Product AST 2$54.92$54.92 
Product BST 4$56.70 $56.70
Product BST 5$56.70  
Product CST 4$57.70$57.70$57.70
Anonymous
Not applicable

Hi @_ajinkyaj 

 

Thank you very much lbendlin and VahidDM for your prompt reply.

 

Please try to get Min using the following code:

 

Min or Max Product-ST = 
var min_value = 
CALCULATE(
        MIN('Table'[Net Price Per Unit]),
        ALLEXCEPT('Table', 'Table'[Product Name])
)
RETURN
IF(
    NOT(ISBLANK(SELECTEDVALUE('Table'[Net Price Per Unit]))),
    min_value
)

 

Here is the result.

 

vnuocmsft_1-1735540332364.png

 

Regards,

Nono Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Please provide sample data that fully covers your issue.
Please show the expected outcome based on the sample data you provided.

lbendlin
Super User
Super User

Please provide a more detailed explanation of what you are aiming to achieve. What have you tried and where are you stuck?

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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.

Top Solution Authors
Top Kudoed Authors