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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
EeeeenieMac
Regular Visitor

Bar chart behaviour

Hi there

 

PLEASE can somebody put me out of my misery?  I've been trying to get to the bottom of this for a couple of days now without any joy.

 

My customer would like to select a Customer and then display 4 summary values from different tables in the same hierarchy.  I've written measures for these and a very simle function that returns the relevant measure depending on the selected axis element.  When I display the results in a matrix or a scatterchart, it works.  However, when I apply the same data to a bar chart, two of the measures are not being displayed.

 

In a previous version of my model this worked perfectly.  Since then I've added another couple of reference tables and it broke.  I've tried to disassemble it to no avail.  I did, however, have to change the relationship direction to Both.

 

EeeeenieMac_0-1700213345930.png

 

 

On selecting the company on the left, the visuals on the right of the grey bar display the measures.  The matrix and scatter are correct but Region & Type are missing from the bar chart.

 

These are the measures:

1. CostPerTonne = calculate(sum('SiteYear Treatment'[Cost])/sum('SiteYear Treatment'[Weight]),'SiteYear Treatment'[Weight]<>0)

2. cptRegion = CALCULATE([CostPerTonne], ALLEXCEPT(TrustYear,TrustYear[FY]), 'Commissioning Region'[CommissioningRegion_ID]= SELECTEDVALUE('Commissioning Region'[CommissioningRegion_ID]))

3. cptType = CALCULATE([CostPerTonne], ALLEXCEPT(TrustYear,TrustYear[FY]), TrustType[TrustType_ID]=SELECTEDVALUE(TrustType[TrustType_ID]))

4. cptAll = CALCULATE([CostPerTonne], ALLEXCEPT(TrustYear,TrustYear[FY]))

 

and this is the 'switch' measure:

cptSwitch =
var _v = max(cptComaprisonTable[Axis])
return
if( _v="Trust", [CostPerTonne],
if( _v="Region", [cptRegion],
if( _v="Type", [cptType],
if( _v="All", [cptAll], 5
))))
 
I'd be so grateful for any suggestions or pointing me in the right direction.
Many thanks
1 REPLY 1
imac
Regular Visitor

I'm happy to say that I have resolved this.  The reason for the behaviour, I think, is because two of my measure yielded <blank> in their default state.  Only when a Company was selected did they correctly calculate.  The BarChart visuals need default values for the outer container.

 

To fix this I simply added IF(ISBLANK([cptMeasure]), [DefaultValue], [cptMeasure]).

 

 

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors
Top Kudoed Authors