# Dax measure doesn't return correct total value in all rows

Brass Contributor

# Dax measure doesn't return correct total value in all rows

Hi,

Created a measure as below:

Its giving me the correct values at filter context and total as well as shown below:

My expected outcome of this measure should be:

total 0.17 should be in all rows of DBName-point id(filter context) and not their individual values(for ex: INSE-1000 should have 0.17 instead of 0.12)

In order to achieve that,i created a measure as below:

But then it gives 0.155 in all rows rather than 0.17

To elaborate with another example:

Sample data.xlsx

Below screenshot shows, dax measure '

Invoice Unit Rate test ' total as  0.12620 Which is correct:

I wrote a measure 'Invoice Unit Rate test 3' as below to display the total of 'Invoice Unit Rate test 2' in all rows:

But my result is as below:

I expect Invoice Unit Rate test 3 dax measure to show values as below:

 DBName-Point_Id Invoice Unit Rate test 2 'Invoice Unit Rate test 3 INSE-1001 0.11078 0.1262 INSE-1004 0.14193 0.1262 Total 0.1262 0.1262

5 Replies

# Re: Dax measure doesn't return correct total value in all rows

I checked only second one.

For DBName-Point_Id you'd like to calculate total for only only two selected points, not for all existing ones. Thus

``````Invoice Unit Rate test 3 =
CALCULATE (
[Invoice Unit Rate test 2],
//    ALL ( Points[DBName-Point_Id] )
ALLSELECTED ( Points[DBName-Point_Id] )
)``````

With previous measure you don't need ALL(Points) since Cost and Units are calculated in current row context. If to remove

``````Invoice Unit Rate test 2 =
VAR Cost = SUM ( 'Invoice Data'[Cost] )
VAR Units = SUM ( 'Invoice Data'[Units] )
VAR div =
CALCULATE ( DIVIDE ( ABS ( Cost ), ABS ( Units ), BLANK () ) ) //,ALL(Points))
RETURN
CALCULATE (
IF ( ISBLANK ( Cost ) || ISBLANK ( Units ), BLANK (), div ),
ALL ( 'Invoice Data' ),
ALL ( 'Calendar' ),
ALL ( Contacts )
)
//,ALL(Points))``````

result will be the same.

Finally

# Re: Dax measure doesn't return correct total value in all rows

Apologise for the delay in getting back as we were testing this measure at different levels!

Many thanks for your amazing solution Sir!

What we found from our testing was as below:

This measure worked amazingly well when we unselect points id and the values are also correct:
Dax:

Result:

When I unselect points, and select either 1 Utility(gas), this shows correct value 0.36:

When i select electricity utility,dax shows 0.15 for all points which is correct:

FYR, some examples of point id's that comes under electricity & gas utility as below for your testing purposes:

The Electric Utility contains below points:

INSE-1000

INSE-1001

INSE-1002

INSE-1003

INSE-998

INSE-324

INSE-41

The gas utility contains points id as below:

INSE-1214

INSE-1215

INSE-1308

Now when I select both utility, it shows wrong value(0.16) for all points as shown below based on utility selected:

When i select both utility, dax should show their corresponding average for their points, (i.e)
The gas utility points should show, 0.36(overall for all gas points) & The Electricity utility points should show 0.15 (overall for all electricity points)

Expected outcome for example point id given above:

This should work when we unselect/show all point id (0.36 for gas & 0.15 for electricity utility) with only 2 utility selected and expected result as below:

PFA file in link Financial Management -Tanvi Copy 3 (3) (2) - Copy - Copy.pbix

# Re: Dax measure doesn't return correct total value in all rows

If to show records when both measures are not blank, you may apply filter to the visual

which gives

# Re: Dax measure doesn't return correct total value in all rows

Perhaps better to modify test3

``````Invoice Unit Rate test 3 =
VAR test2 = [Invoice Unit Rate test 2]
RETURN
CALCULATE (
test2, // [Invoice Unit Rate test 2],
ALLSELECTED ( Points[DBName-Point_Id]  )
)``````

With that if [Invoice Unit Rate test 2] is blank, [Invoice Unit Rate test 3] is also returns blank and no need to apply filter to visual

# Re: Dax measure doesn't return correct total value in all rows

Apologise for not giving the clear explanation!

My expected result is as below:

When I select the utility as gas from utility slicer, this measure in below table should show 0.36 for DBName-Poind_id column

and 0.15 when we select Electricity.

We don't have to worry about Invoice Unit Rate test 2 measure showing blank values/cells and neither for Invoice Unit Rate test 3.

I am just confused how/whether to modify Invoice Unit Rate test 3 or Invoice Unit Rate test 2 measure in order to achieve above?