Add ability to query empty members from Cube.query()
#688
Harold7665
started this conversation in
General
Replies: 1 comment
-
To add more context this could be required for a customer wishing to see factless hierarchies members with no contributors: import pandas as pd
import atoti as tt
session = tt.Session()
timeTable = session.read_pandas(
pd.DataFrame(
columns=["MonthKey", "YearKey", "QuarterKey", "MonthName"],
data=[
("2022M01", "2022", "2022Q1", "Jan 2022"),
("2022M02", "2022", "2022Q1", "Feb 2022"),
("2022M03", "2022", "2022Q1", "Mar 2022"),
("2022M04", "2022", "2022Q2", "Apr 2022"),
("2022M05", "2022", "2022Q2", "May 2022"),
("2022M06", "2022", "2022Q2", "Jun 2022"),
("2022M07", "2022", "2022Q3", "Jul 2022"),
("2022M08", "2022", "2022Q3", "Aug 2022"),
("2022M09", "2022", "2022Q3", "Sep 2022"),
("2022M10", "2022", "2022Q4", "Oct 2022"),
("2022M11", "2022", "2022Q4", "Nov 2022"),
("2022M12", "2022", "2022Q4", "Dec 2022"),
],
),
table_name="time",
keys=["MonthKey"],
)
factTable = session.read_pandas(
pd.DataFrame(
columns=["AccountKey", "TimeKey", "Revenue"],
data=[
("REVENUE", "2022M01", 1050),
("REVENUE", "2022M02", 900),
("REVENUE", "2022M04", 300),
("REVENUE", "2022M05", 200),
("REVENUE", "2022M07", 400),
("REVENUE", "2022M08", 100),
("REVENUE", "2022M09", 100)
],
),
table_name="fact",
keys=["TimeKey", "AccountKey"],
)
factTable.join(timeTable, mapping={'TimeKey':'MonthKey'})
session.tables.schema
cube = session.create_cube(factTable, mode='no_measures')
m, l, h = cube.measures, cube.levels, cube.hierarchies
h['Time'] = {
'Years': timeTable['YearKey'],
'Quarters': timeTable['QuarterKey'],
'Months': timeTable['MonthKey']
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
Could you add a parameter to the
Cube.query()
in order to choose on ROWS and on COLUMNS (maybe not both at the same time) if we want theNON EMPTY
clause or not?This may be common for customers starting by working with a "global hierarchy" before adding facts on the nodes and leaves.
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions