cancel
Showing results for
Did you mean:
New Member

## Issue with DAX calculation being correct at detail level, but not intermediary

Hello,

I have some calculations I'm working on in regards to breakeven bushels per acre. What I am seeing is that if I have a table showing data at the lowest level in a table visual, it works fine. The calculation is also correct at the total (all crops) level. It's a basic calculation of Total Expenses / Actual Harvested Acres.

However, when I use a hierarchy and show the data in a summarized form, the calculation is doing something different. The calculation works at an individual field level, but when the data is in a different visual and shown at the crop level (multiple fields), I'm not sure how I need to change the calculation. I think I'm missing something in regards to getting just the subset records.

In my PBIX file, I have a few sample measures.

BREAKEVENV3 =
VAR TEXP = [Total Expenses]
VAR AHA = SUM(Class[Actual Harvested Acres])
RETURN
DIVIDE(TEXP,AHA,0)

Breakeven Bushels Per Acre (v2) =
//stores what I think is total for the class
VAR CLASSHARVEST = sum(Class[Actual Harvested Acres])
RETURN
if(
ISFILTERED('GL Transactions'[Crop]),
DIVIDE([Total Expenses], CLASSHARVEST ,0),
DIVIDE([Total Expenses],
CALCULATE( SUM(Class[Actual Harvested Acres]),ALLSELECTED('GL Transactions'[Class])),0))

Hieararchy is:

Crop (Corn, Wheat, Soybeans)

Class (Individual field)

I have written this calculation a few different ways with similar results so I think it is a logic error I'm missing.

The total level is correct (122109.4 Total expenses / 1320.1 Acres = 92.50008)

Both breakeven calculations are correct, see example for winter wheat:

B1: (27091.39 / 283.90 = 95.43)

B2: (5312.06 / 53 = 100.23)

Crop level incorrect:

Expected value for Winter wheat: 32403.45 / 336.9 = 96.18121

Actual value for Winter wheat: 24.55

Thanks for any suggestions. I've found numerous posts pointing to do a percentage of total calculation that needs to be adjusted, but I think my problem needs to be solved by ensuring I have the correct subset of records, which I think is where I am going wrong.

Edit1: Here is an updated link that looks to work for me.

https://ryandevsmore-my.sharepoint.com/:u:/g/personal/ryandevs_ryandevsmore_onmicrosoft_com/ESPQEsB7...

1 ACCEPTED SOLUTION
Super User

Hi,

Hope this helps.

Regards,
Ashish Mathur
http://www.ashishmathur.com
5 REPLIES 5
New Member

Hi @Ashish_Mathur, Thanks for taking the time to reply. It does indeed look like your suggestion resolved the issue.

It appears the issue was that my hieararchy was returning different results versus individually dragging the different hieararchy values in.

If this is by design or if there is any documentation to relect this, I'd love to know a little more. Otherwise I'm happy with the issue resolved. Thank you again!

Super User

You are welcome.

Regards,
Ashish Mathur
http://www.ashishmathur.com
New Member
Super User

Hi,

Hope this helps.

Regards,
Ashish Mathur
http://www.ashishmathur.com
Super User

FYI, I can't access the link you shared. You might want to adjust the permission settings.

Announcements

#### Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

#### The Power BI Community Show

Welcome to the Power BI Community Show! Jeroen ter Heerdt talks about the importance of Data Modeling.

#### Check it out!

Mark your calendars and join us on Thursday, May 26 at 11a PDT for a great session with Ted Pattison!

#### Charticulator Design Challenge

Put your data visualization and design skills to the test! This exciting challenge is happening now through May 31st!

Top Solution Authors
Top Kudoed Authors