Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
dselgo_eidex
Partner - Creator III
Partner - Creator III

Set analysis using dimension value

Hello, so I have a table below which contains information on schools and their respective school districts:

Entity CodeEntity TypeDistrict CodeEntity Name

1001

Building1000School A
1002Building1000School B
1003Building1000School C
1004Building1000School D
1005Building1000School E
1000District1000District A

As you can see, each Building has an associated District Code. What I am trying to do is create a Straight Table like the following:

BuildingDistrict
School ADistrict A
School BDistrict A
School CDistrict A
School DDistrict A
School EDistrict A

For this straight table, I have Entity Name as the primary dimension, and I'm trying to figure out how to set up the set analysis to get the associated District Name. Right now I have

only({1<[Entity Type] = {'District'}, [District Code] = {$(=only({1} [District Code]))}>} [Entity Name])

but this is resulting in NULL values for District. I guess I'm just having trouble with understanding how the set analysis plays with the chart dimension and how to return the Entity Name on a different row.

1 Solution

Accepted Solutions
sunny_talwar

May be this

=Aggr(If([Entity Type] <> 'District', Only(TOTAL {<[District Code]>} {<[Entity Type] = {'District'}>} [Entity Name])), [Entity Name], [District Code])

Capture.PNG

View solution in original post

8 Replies
sunny_talwar

May be this

=Aggr(If([Entity Type] <> 'District', Only(TOTAL {<[District Code]>} {<[Entity Type] = {'District'}>} [Entity Name])), [Entity Name], [District Code])

Capture.PNG

dselgo_eidex
Partner - Creator III
Partner - Creator III
Author

Sunny, could you explain why you have {<[District Code]>} {<[Entity Type] = {'District'}>}


I've never seen two set expressions like that before. Also, what does having [District Code] in its own set expression do?

sunny_talwar

My bad, I wanted to do this

=Aggr(If([Entity Type] <> 'District', Only(TOTAL <[District Code]> {<[Entity Type] = {'District'}>} [Entity Name])), [Entity Name], [District Code])

Incorrectly placed {} around <[District Code]>, but this is used for TOTAL qualifier and the other part is the set analysis

dselgo_eidex
Partner - Creator III
Partner - Creator III
Author

Thanks for the help Sunny! That worked out perfectly.

vinieme12
Champion III
Champion III

I would suggest breaking the table in 2,

table 1 : WHERE ENTITY = SCHOOL

Entity CodeDistrict CodeEntity Name

1001

1000School A
10021000School B
10031000School C
10041000School D
10051000School E

Left JOIN

table 2 :  WHERE ENTITY = DISTRICT

District CodeEntity Name
1000District A
Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
dselgo_eidex
Partner - Creator III
Partner - Creator III
Author

Normally I would agree, it would make things like this easier. But because of the way that I have my data model set up and the way that I need my app to perform, having both on the same table works better.

vinieme12
Champion III
Champion III

You just need to to join them as columns

LOAD

EntityCode,districtCode,EntityName

Where Entity = 'School';

Left join

LOAd  districtCode,EntityName as districtname

Where Entity = 'district';

using AGGR could possibly slow down app performance depending how many unique values the fields you are aggregating by

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
dselgo_eidex
Partner - Creator III
Partner - Creator III
Author

I'm aware of the potential hit to app performance, but there are a relatively small number of unique values to AGGR over so I feel confident that it should be minimal. But I always do have the backup plan of joining [District Name] onto the table.