Forum Discussion

cottrera's avatar
cottrera
Post Prodigy
4 years ago
Solved

DAX Average & Model issue

Hi 

 

I am trying to visualise the average repairs spend for all properties in a visual table. I would like to still see the property that have no repairs. Also when I filter the types of repairs. I still which to see all the properties and only the avg spend result change

hope I have explained that ok

 

I have a model that contains 2 tables. Tabe 1 = Properties. In the example below there are 5 properties (one property per row)

Property RefProperty TypeBuilt Year
1House2003
2Flat1985
3House1971
4Flat1955
5House2003

 

Table 2 = Repairs (Many repairs per property)

Property RefTradeSpend over 5 years
1Plumbing£1,010
1Brick£802
2Electrical£332
2Roof£744
2Plumbing£982
2Plumbing£624
3Brick£1,026
3Electrical£785
3Plumbing£892
5Brick£977
5Brick£47
5Plumbing£1,142
5Electrical£687
5Electrical£1,115
5Brick£480

 

I have 2 measures

 

Spend := SUM(Repairs[Spend over 5 years])

 

Average Spend =AVERAGEX(VALUES(Property'[Property Ref] ),
  DIVIDE([Spend],5))   // Avg spend over 5 years

The model looks like this

 

The first issue is when I display the results in a visual table the property that has no repairs / spend information is missing (Property Ref 4)  I need to see this row but with £0

The second issue is that when I filter the table visual by Trade (Repairs table) the properties that do not contain repairs with this type of trade dissapear.

What I would expect to see firstly would be this

Property RefProperty TypeBuilt YearSpendAverage Spend
1House2003£1,812£362.40
2Flat1985£2,682£536.40
3House1971£2,703£540.60
4Flat1955  
5House2003£4,448£889.60

 

And when I filter by trade I would expect to see this

Property RefProperty TypeBuilt YearSpendAverage Spend
1House2003  
2Flat1985£332£66.4
3House1971£785£157
4Flat1955  
5House2003£1802£360.4

 

thanks

Richard