I need to create a Calculation
in SQL Server Data Tools.
Imagine that in my OLAP framework I have the Dimensions City and Reseller, and a Sales Fact. In the City dimension I have City, State and Population, and that Population is a measure in one dimension, making the city dimension a Fact and a Dimension at the same time.
I need to add the Population in the cities from which a reseller had sales. But I can not add just the population of the cities with sales, I can only show the state total. Remembering that a seller can sell in several cities and in more than one state.
I filtered through the retailer John and the query returned this:
STATE | CITY | POPULATION
CA | Los Angeles | 10.000.000
CA | San Francisco | 1.000.000
CA | Sacramento | 1.000.000
CA | San Diego | 1.000.000
CA | Bakersfield | 500.000
Total 37.000.000
The sum should return 13,500,000, but for me, the sum returns 37,000,000, which is the total population of California.
The calculation I currently use, is
SUM([Measures].[Population])
I do not have advanced knowledge in MDX, I could not mount the calculation yet just this:
SUM(FILTER([Measures].[Population],[Sales Amount]>0))
or this
SUM(NONEMPTY(( [CidadesRadiografia].[Cidade].[Cidade],
[Measures].[População],
[RepresentantesRadiografia].[Representante].[Representante] )))
In short, I need to return only the sum of the population to the cities that the reseller had sales, but currently it shows the total population, for example, if I select the country and the city, returns the total sum of the country , and if I select the state and city, it returns the sum of the population of the state.
Question no StackOverflow