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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
M_SBS_6
Helper V
Helper V

Incorrect Totals - Matrix

Hi, 

I have the following measure which works as expected however, the grand totals don't show the expected value.

 

I have tried to add in HASONEVALUE, SUMX and create new measures on the back of this, but whatever I try, I just can't work out how to correctly do it. Would anyone know how to amend my current logic to get this to work or, a separate measure based on this logic please? 

Measure = 
  VAR __AppStatus = MAX('apps'[app_status])
  VAR __IsPriorMonth = MAX('month_index'[is_prior_month])
  VAR __AppValue = MAX('apps'[app_value])
  VAR __Result =
    SWITCH( TRUE(),
      __AppStatus = "live" && __IsPriorMonth = "yes", 0,
      ( __AppStatus = "test" && __IsPriorMonth = "yes" ) ||
        ( __AppStatus = "test" && __AppValue < 30 ), 0,
      SUM('apps'[amount])
    )
RETURN
  __Result

 

As an example, I have have this total below as 50, but based on the output, I should have 20. It seems like the total is ignoring the logic and just taking the total regardless l.

 

          Jan Feb Mar Total

Live    0.    10.   10.  50

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @M_SBS_6 ,

I created some data:

vyangliumsft_0-1684303308077.png

Here are the steps you can follow:

 

1. Create measure.

 

Measure2 =
var _table1=
SUMMARIZE(
    'Table','Table'[Group],"Value1",[Measure])
var _table2=
SUMMARIZE(
    'Table','Table'[Group2],"Value2",[Measure])
return
IF(
    NOT(HASONEVALUE('Table'[Group2])),SUMX(_table2,[Value2]),
    IF(
        NOT(HASONEVALUE('Table'[Group])),SUMX(_table1,[Value1]),[Measure])
)

 

2. Result:

vyangliumsft_1-1684303308082.png

 

Best Regards,

Liu Yang

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

4 REPLIES 4
Anonymous
Not applicable

Hi  @M_SBS_6 ,

I created some data:

vyangliumsft_0-1684303308077.png

Here are the steps you can follow:

 

1. Create measure.

 

Measure2 =
var _table1=
SUMMARIZE(
    'Table','Table'[Group],"Value1",[Measure])
var _table2=
SUMMARIZE(
    'Table','Table'[Group2],"Value2",[Measure])
return
IF(
    NOT(HASONEVALUE('Table'[Group2])),SUMX(_table2,[Value2]),
    IF(
        NOT(HASONEVALUE('Table'[Group])),SUMX(_table1,[Value1]),[Measure])
)

 

2. Result:

vyangliumsft_1-1684303308082.png

 

Best Regards,

Liu Yang

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

Ahmedx
Super User
Super User

what kind of return, I asked to write

= SUMX(VALUES('Date'[MonthName],[Measure])
Ahmedx
Super User
Super User

write another measure like this
SUMX(VALUES('Date'[MonthName],[Measure])

Screen Capture #1088.png

Thanks for your suggestion. I have tried that but get thr following error message 

 

The syntax for 'RETURN' is incorrect 

Not too sure why? 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.