DataBrewery / cubes

[NOT MAINTAINED] Light-weight Python OLAP framework for multi-dimensional data analysis
http://cubes.databrewery.org
Other
1.49k stars 313 forks source link

ERROR Internal Cubes error (ExpressionError): Unknown attribute 'u'date1_item' #469

Open ashutoshgaurav opened 5 years ago

ashutoshgaurav commented 5 years ago

i am trying to create a fresh cube based on hello_world example. but i am not able to get how to make changes in model.json file in aggrgate and measures categories. if want genrate a column with a difference of two columns then this shows an error like this ERROR Internal Cubes error (ExpressionError): Unknown attribute 'u'date1_item' please help.

my json file is: "cubes": [ { "name": "node_balance", "dimensions": ["item", "year_item"], **"measures": [ {"name":"duration", "label":"Duration", "expression": "date1_item - date2_item"}

        ],
        "aggregates": [
            ],**
        "mappings": {
                      "item.line_item": "line_item",
                      "item.subcategory": "subcategory",
                      "item.subcategory_label": "subcategory_label",
                      "item.category": "category",
                      "item.cpu_item": "cpu_item",
                      "item.category_label": "category_label",
                      "item.year_item": "year_item",
                      "item.date1_item": "date1_item",
                      "item.date2_item": "date2_item"
                     },
        "info": {
            "min_date": "2010-01-01",
            "max_date": "2010-12-31"
        }
    }
ThamaluM commented 4 years ago

Hi @ashutoshgaurav according to my experience with cubes expressions in measures contains other measures not attributes. In your expression date1_item and date2_item are not defined as measures. (Cubes do not directly get data from relevant column in fact table. You have to define two another measures for them.)

"measures": [ {"name":"date1_item"}, {"name":"date2_item"}, {"name":"duration", "label":"Duration", "expression": "date1_item - `date2_item"} ]