Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Measures in joined table do not aggregate #663

Open
Wi1iku opened this issue Aug 5, 2022 · 1 comment
Open

Measures in joined table do not aggregate #663

Wi1iku opened this issue Aug 5, 2022 · 1 comment
Assignees
Labels
🐛 bug unexpected or wrong behavior

Comments

@Wi1iku
Copy link

Wi1iku commented Aug 5, 2022

Issue

The problem I'm facing is that when I try to aggregate the measure from the Sensis table (not the base store)
I can´t aggregate the measure sensitivity to every hierarchy from the base store (not even by the fields used to join both tables).
However, the measure called PL.SUM has the functionality to be aggregable by every hierarchy.
What we would like to know is if there is any method or attribute for measures from other stores (that are not the base store) to
have the functionality to be aggregable by any base store hierarchy, just like PL.SUM.
I know it is possible to create a new measure that aggregates the original measure to a certain hierarchy, but it is not efficient to
be creatinga measure every time I want to aggregate the measure to a different hierarchy, as it happens with measures from the
base store, they can be aggregable without creating new measures.

Thank you very much!

Steps to reproduce

Code

Whole notebook code

import atoti as tt
import pandas as pd
import numpy as np
session = tt.Session(port=9080)
df_pl = pd.read_csv('Base_Store_PL_ex.csv', sep = ';')
df_pl.head()
df_sens = pd.read_csv('sensis_ex.csv', sep = ';')
df_sens.head()
pl_store = session.read_pandas(\n,
    df_pl,\n,
    keys=['asOfDate', 'country', 'portfolio', 'deal'],\n,
    table_name=\PL\)
sensis_store = session.read_pandas(\n,
    df_sens,\n,
    keys=['asOfDate', 'country', 'portfolio', 'deal', 'underlying'],\n,
    table_name=\Sensis\)
cube = session.create_cube(pl_store)
pl_store.join(sensis_store, mapping={\asOfDate\: \asOfDate\, 'country': 'country', 'portfolio': 'portfolio', 'deal': 'deal'})
m, h, l = cube.measures, cube.hierarchies, cube.levels
cube
m['sensitivity'] = tt.value(sensis_store[\sensitivity\])
session.link()

Actual Result

Does not aggregate measures automaticly
Doesnt_aggregating_sensitivity_but_aggregates_PL

Expected Result

When not aggregating from sensis tables, measures are created
Comparison

Environment

  • atoti: 0.6.6
  • Python: 3.10
  • Operating System: win32

Logs (if relevant)

Aditional Data

dataModel

@Wi1iku Wi1iku added the 🐛 bug unexpected or wrong behavior label Aug 5, 2022
@Skyscimitar
Copy link

Skyscimitar commented Aug 5, 2022

Hi,

The tt.value function creates a measure representing the value of the column, it doesn't provide any information on how to aggregate it. The value function propagates the value of the column through levels as long as it stays the same (see the documentation for a more detailed example. In the screenshot you shared, since all the sensitivity values are different, without information on how to aggregate it there is no value to display using only the as_of_date and country levels, therefore the value is None and the column in the pivot table is not displayed since it contains no data.

You can use any of the functions in the tt.agg module to create aggregated measures.
For example, if you want the sum of your sensitivities you can use tt.agg.sum(sensis_store["sensitivity"])

@Wi1iku Wi1iku changed the title Measures in base table do not aggre Measures in joined table do not aggregate Aug 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug unexpected or wrong behavior
Projects
None yet
Development

No branches or pull requests

2 participants