cancel
Showing results for 
Search instead for 
Did you mean: 

Sum column (flag = 1) problem

Former Member
0 Kudos

Hello guys,

I'm facing a curious problem here with HANA. I have a simple Calculation View with only one proyection with a table as a source where I want to create a Calculation Column that will work as a flag and it will be 1 or 0 dependant of some contitions.

The problem comes when I try to sum this column because it not sums 1's it only display 1 or 0.

For example, I have this table with the FLAG_ACTIVE calculation column created:

ClientCountryFLAG_ACTIVE
AUSA1
BUSA1
CUSA1
DUSA0
FCANADA1
G

CANADA

0
H
CANADA
0
I
CANADA
1

The FLAG_ACTIVE is a INTEGER Calculated Column and in the semantic layer show a Sum as the aggregation method.

But if I try to check the results in the Data Preview, if I select Country and FLAG_ACTIVE, it gives me the following result:

COUNTRYFLAG_ACTIVE
USA1
CANADA1

But it is wrong as USA should be 3 and CANADA 2

How can I archieve my requirement?

I have also tried to create another calculation view over this one to try to create another calculation column from the flag, but the result is the same, it doesn't aggregates, it only shows 1 or 0

Any tips?

Thank you very much

Accepted Solutions (0)

Answers (1)

Answers (1)

anindya_bose
Active Contributor
0 Kudos

Hi Alejandro

Are you checking in "RAW DATA" tab or "Analysis" tab.  Pull only Country and Flag objects in Analysis tab. Do you see it aggregated ?  If not, share a screenshot .

Under "View Properties" of Calculation View, what is the "Data Category" ?

Regards

Anindya

Former Member
0 Kudos

Hello Anindya,

I'm checking the results in the analysis tab only with the Country and Flag objects and it doesn't aggregate the flag column. It only shows the country and 1 for each country.

Data Category is CUBE.

Thanks

former_member182302
Active Contributor
0 Kudos

Can you share the query it is framing from the "view log" in the data priview?

Regards,

Krishna Tangudu

anindya_bose
Active Contributor
0 Kudos

I do not really expect HANA to have any such bug, and probably it is not the case.   Can you compare my screenshot with your data model .

MODEL

RAW DATA

Analysis Tab

Former Member
0 Kudos

Hello Anindya Bose,

I've been researching a bit more and I have found something WEIRD...

If I build the model with a physical table in the proyection node, IT WORKS! and the result is correct:

But if I build the model with an analytical view as a source in the proyection node, it doesn't work...

Can you reproduce this issue? The Analytical view has only the physical table.

The table is this:

Any help will be appreciated, Thanks!

anindya_bose
Active Contributor
0 Kudos

It seems you defined the Calculated Column in "Projection Node" . Here you are basically defining an "Attribute" type Integer, example ZIP/PIN code which should not be aggregated meaningfully . 

You can define this Calculated Column either in "Aggregation" node of Calculation View or Analytic View itself and let me know if issue persists.

Regards

Anindya

former_member182302
Active Contributor
0 Kudos

Did you check the explain plan? if so the difference should be "DISTINCT" being applied in the case of Analytic view before aggregation . Let us know once you checked. May be one more case which says as SAP recommends not to use Attribute or Analytic Views any more.

Regards,

Krishna Tangudu