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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
GrazieGracias
New Member

Apply measure only for a particular row

Hello,

 

I have a data set that summarizes the following items by Month and by Store.

  1. Sales
  2. Profit
  3. Operating Expenses
  4. Other Expenses
  5. Net Income (=Profit - Operating Expenses - Other Expenses)
  6. Margin (=Profit / Sales)

The aforementioned data set looks like below:

Capture2.JPG

(Name of the table: Table1)

 

My task is to create a table in PowerBI like below:

Capture.JPG

 

The problem I am trying to solve at the moment is to make Margin recalculated when multiple months are selected in the slicer (e.g., to show YTD amounts); As you can see below, Margin it sums up the margins for selected months instead of recalculating it, which I understand why.

Capture3.JPG

 

To make it recalculate Margin when multiple months are selected, I created the following measures, but it's not displaying anything for Margin.

AmountA:=CALCULATE(SUM(Table1[Amount]),Table1[Store]="A")

AmountAMargin:=CALCULATE([AMountA],Table1[Description]="Profit")/CALCULATE([AMountA],Table1[Description]="Sales")

AmountAFinal:=SUMX(Table1,SWITCH(TRUE(),Table1[Description]="Margin",[AmountAMargin],[AmountA]))

 

Capture4.JPG

 

Can you please advise?

 

Thanks much,

GrazieGracias

1 ACCEPTED SOLUTION
v-yuta-msft
Community Support
Community Support

@GrazieGracias ,

 

In general, this issue should be related to the the conditions in the measure haven't been met, so you may add ALL() function in your filter. Try modifying your code like dax below and check if the value is still blank. If this leads to other issue or incorrect value, please provide the expected result.

AmountA =
CALCULATE (
    SUM ( Table1[Amount] ),
    FILTER ( ALL ( Table1 ), Table1[Store] = "A" )
)


AmountAMargin =
CALCULATE (
    SUM ( Table1[Amount] ),
    FILTER ( ALL ( Table1 ), Table1[Description] = "Profit" && Table1[Store] = "A" )
)
    / CALCULATE (
        SUM ( Table1[Amount] ),
        FILTER ( Table1, Table1[Description] = "Sales" && Table1[Store] = "A" )
    )


AmountAFinal =
SUMX (
    Table1,
    IF ( MAX ( Table1[Description] ) = "Margin", [AmountAMargin], [AmountA] )
)

Community Support Team _ Jimmy Tao

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

3 REPLIES 3
v-yuta-msft
Community Support
Community Support

@GrazieGracias ,

 

In general, this issue should be related to the the conditions in the measure haven't been met, so you may add ALL() function in your filter. Try modifying your code like dax below and check if the value is still blank. If this leads to other issue or incorrect value, please provide the expected result.

AmountA =
CALCULATE (
    SUM ( Table1[Amount] ),
    FILTER ( ALL ( Table1 ), Table1[Store] = "A" )
)


AmountAMargin =
CALCULATE (
    SUM ( Table1[Amount] ),
    FILTER ( ALL ( Table1 ), Table1[Description] = "Profit" && Table1[Store] = "A" )
)
    / CALCULATE (
        SUM ( Table1[Amount] ),
        FILTER ( Table1, Table1[Description] = "Sales" && Table1[Store] = "A" )
    )


AmountAFinal =
SUMX (
    Table1,
    IF ( MAX ( Table1[Description] ) = "Margin", [AmountAMargin], [AmountA] )
)

Community Support Team _ Jimmy Tao

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

Thanks for the help. I tweaked the codes a little bit and it works beautifully. The key ingredient was MAX, and I actually didn't have to use SUMX.

 

Thanks again!

GrazieGracias

 

Stachu
Community Champion
Community Champion

I'd try something like this:

AmountAFinal :=
IF (
    SELECTEDVALUE ( Table1[Description] ) = "Margin",
    [AmountAMargin],
    [AmountA]
)


Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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