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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
spartanboy
Helper II
Helper II

Calculate DAX for a Context

Hi,

 

Below is a table where PERIOD_1 & PERIO_2 are selected by the user, hence these are from the original table columns, the section "CHANGE" is dynamic calculation performed per user selection on P1 & P2. I am able to calculate the COST_DELTA, but need help in creating a DAX measure for MIN_COST_DELTA for each SKU, and this value should remain Static irrespective to users selection of LOCATION using filters.

 

  PERIOD 1PERIOD 2CHANGE
SKULOCATIONCOSTCOSTCOST_DELTAMIN_DELTA_COST
ABC_123A1 $    1.100 $    1.500 $           0.400 $                    (0.150)
ABC_123A2 $    1.150 $    1.200 $           0.050 $                    (0.150)
ABC_123A3 $    1.450 $    1.600 $           0.150 $                    (0.150)
ABC_123A4 $    1.200 $    1.050 $         (0.150) $                    (0.150)
ABC_123A5 $    1.000 $    1.200 $           0.200 $                    (0.150)
DEF_234B1 $    2.400 $    2.200 $         (0.200) $                    (0.400)
DEF_234B3 $    3.000 $    2.600 $         (0.400) $                    (0.400)
DEF_234B6 $    2.800 $    2.400 $         (0.400) $                    (0.400)
DEF_234B8 $    1.900 $    2.700 $           0.800 $                    (0.400)

 

1 ACCEPTED SOLUTION
sevenhills
Super User
Super User

You can try this also:

To calculate difference in cost (measure)

Diff Cost = sum('Table'[Period 2 COST]) - Sum('Table'[Period 1 COST])


To calculate minimum of difference in cost in each SKU (measure):

Min Diff Cost by SKU = 
Minx ( FILTER( all ('Table'), 'Table'[SKU] = SELECTEDVALUE('Table'[SKU]))
       , [Diff Cost])


 Output:

sevenhills_1-1725162130751.png

 

sevenhills_2-1725162164483.png

 

 

View solution in original post

2 REPLIES 2
sevenhills
Super User
Super User

You can try this also:

To calculate difference in cost (measure)

Diff Cost = sum('Table'[Period 2 COST]) - Sum('Table'[Period 1 COST])


To calculate minimum of difference in cost in each SKU (measure):

Min Diff Cost by SKU = 
Minx ( FILTER( all ('Table'), 'Table'[SKU] = SELECTEDVALUE('Table'[SKU]))
       , [Diff Cost])


 Output:

sevenhills_1-1725162130751.png

 

sevenhills_2-1725162164483.png

 

 

DataNinja777
Super User
Super User

Hi @spartanboy ,

 

By using minx, the following measure calculates the minimum cost difference for each SKU across all locations, ignoring any LOCATION filter set by the user.

MIN_COST_DELTA =
CALCULATE (
    MINX (
        ALL ( 'YourTableName'[LOCATION] ),
        -- This ignores any filters on the LOCATION column
        'YourTableName'[COST_DELTA]
    ),
    ALLEXCEPT (
        'YourTableName',
        'YourTableName'[SKU]
    ) -- This keeps filters only on SKU
)

Best regards,

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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