DAX FORMAT function cause cartesian product on Power BI visual

纵然是瞬间 提交于 2021-02-20 03:50:22

问题


I have the following SSAS Tabular model defined:

On the Product table, I have the following measures defined:

  1. DeliveryQty2018:= CALCULATE ( SUM ( PurchaseDelivery[PurchaseOrderQuantity] ), ( PurchaseEstimatedWarehouseArrivalDate[PurchaseEstimatedWarehouseArrivalYear] = 2018 ) )
  2. DeliveryQty2019:= CALCULATE ( SUM ( PurchaseDelivery[PurchaseOrderQuantity] ), ( PurchaseEstimatedWarehouseArrivalDate[PurchaseEstimatedWarehouseArrivalYear] = 2019 ) )
  3. Sum DeliveryQty 2018-2020: = FORMAT([DeliveryQty2018] + [DeliveryQty2019] + [DeliveryQty2020],"# ### ###")

I'm creating a table visual on my Power BI report, that consists of the following fields:

This combinations gives me a cartesian product of: Product X ProductCategory:

What's interesting, when I remove the FORMAT() wrapper for the Sum DeliveryQty 18-20, cartesian product is removed and I achieve the single record I was loooking for. However, if I remove the ProductCategory field and leave the Sum DeliveryQty 18-20 measure with the FORMAT() function in place I also get the single record..

Can anyone explain to me what's going here in both scenarios?


回答1:


FORMAT turns blanks (nulls) into empty strings "" rather than proper blanks, so you probably want to check for that first before formatting.

Sum DeliveryQty 2018-2020: =
VAR Qty = [DeliveryQty2018] + [DeliveryQty2019] + [DeliveryQty2020]
RETURN
    IF ( ISBLANK ( Qty ), BLANK(), FORMAT ( Qty, "# ### ###" ) )


来源:https://stackoverflow.com/questions/65008244/dax-format-function-cause-cartesian-product-on-power-bi-visual

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!