Hi!
I have a dataset, called purchase , which consists of two data models:
- purchase_report.model
- flag_must_have_item.model
I’ve set a many-to-one relationship using product_code as join key in the dataset level.
I want to get number of purchases from purchase_report, where the purchased product have fresh_flag = ‘Fresh’ or flag_MHI = ‘MHI’ (must have item). But the issue is fresh_flag field is available in purchase_report.model, whilst flag_MHI is in flag_must_have_item.model.
I’m aware that CONDITIONS in holistics dataset explorer can’t handle OR operation for multicolumn filtering. So I came out with using business calculation in condition, with these code:
case(
when: or(purchase_report.fresh_flag == 'Fresh', flag_must_have_item.flag_MHI == 'MHI')
, then: 1
, else: 0
)
then I select equals to 1 for that business calculation condition.
Since I only select 1 field, which is only purchase_order_id (from purchase_report.model) and I count it, it expected to be only display 1 row - 1 column table. But the result is like this:
Turns out the result is table with 1 column and 2 rows like shown on the pic above. Apparently the executed query is came out like this:
#standardsql
WITH `flag_must_have_item` AS (
#standardsql
SELECT
*
FROM `flag_must_have_item`
WHERE active_end_date >= current_date('Asia/Jakarta')
)
SELECT
`purchase_report`.`fresh_flag` AS `empr_nf_75a6bf`,
`flag_must_have_item`.`flag_mhi` AS `tmbl_n_d2aaf5`,
COUNT(`purchase_report`.`purchase_order_no`) AS `c_empr_cpon_ac6837`
FROM
`purchase_report`
LEFT JOIN `flag_must_have_item` ON `purchase_report`.`product_code` = `flag_must_have_item`.`product_code`
GROUP BY
1,
2
ORDER BY
3 DESC
LIMIT 100000
I don’t get it why it adds two preceding columns before my only desired count purchase_order_id column. I believe it must be has something to do with the business calculation filter/condition, but I have no idea why.
Any solutions to get me fix the table result so it only show count purchase_order_id column as I expected with such cross-model OR filtering?
Thanks
~ Tio