Forum Discussion

abc_777's avatar
abc_777
Solution Specialist
3 years ago
Solved

hi

 

I have

 

Purchased Both Products Quantity =
VAR InitialPurchase = VALUES('bm_retail_t sale'[customer index to Sale])
VAR ComparisonPurchase = CALCULATETABLE(VALUES('bm_retail_t sale'[customer index to Sale]), ALL('bm_retail_t product_file'),
        TREATAS(VALUES('Comparison product'[Product_file Index]),'bm_retail_t sale'[Product index to sale]))
RETURN
    IF (
        SELECTEDVALUE('bm_retail_t product_file'[ITEM_NAME]) = SELECTEDVALUE('Comparison product'[ITEM_NAME]),
        BLANK(),
        CALCULATE (
            [Total in Piece and KG (Measure)],
            INTERSECT ( InitialPurchase, ComparisonPurchase )
        )
    )
 
and 
Quantity Comparison Product =
CALCULATE (
    [Total in Piece and KG (Measure)],
  --  IF(HASONEVALUE('bm_retail_t product_file'[ITEM_NAME]),
   ALL('bm_retail_t product_file'),
 
    TREATAS (
        VALUES('Comparison product'[Product_file Index]),
        'bm_retail_t sale'[Product index to sale]
    )
)
 
and 
 
Filtered Quantity Comparison Product =

VAR PurchasedBoth = [Purchased Both Products Quantity]
VAR ComparisonProduct = [Quantity Comparison Product]
RETURN
    IF (
        NOT(ISBLANK(PurchasedBoth))
            && NOT(ISBLANK(ComparisonProduct))
            && PurchasedBoth <> BLANK(),
        ComparisonProduct,
        BLANK()
    )

 

 

 

total as per above pic should be 

Filtered Quantity Comparison Product = 1 and 
Purchased Both Products Quantity = 1
 
 
please correct follwoing any one the measure
 
Purchased Both Products Quantity1 =

([Purchased Both Products Quantity] + [Filtered Quantity Comparison Product])
 
OR
 
Purchased Both Products Quantity1 =
 VAR CurrentRowQuantity = [Purchased Both Products Quantity]
VAR CurrentRowFilteredQuantity = [Filtered Quantity Comparison Product]
RETURN
    IF (
        NOT(ISBLANK(CurrentRowQuantity))
        && NOT(ISBLANK(CurrentRowFilteredQuantity)),
        CurrentRowQuantity + CurrentRowFilteredQuantity,
        BLANK()
    ) 
   
)
 
 
 
so i can see Purchased Both Products Quantity1 total as 1 which is logical. want to add cell value of Filtered Quantity Comparison Product and Purchased Both Products Quantity
 
 
Really need help
 
thanks

 

  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi abc_777 ,

    Please update the formula of measure [Purchased Both Products Quantity1] as below and check if it can return the expected result...

    Purchased Both Products Quantity1 =
    VAR PurchasedBoth = [Purchased Both Products Quantity]
    VAR ComparisonProduct = [Quantity Comparison Product]
    RETURN
        SUMX (
            VALUES ( 'bm_retail_t product_file'[ITEM_NAME] ),
            SUMX (
                VALUES ( 'Comparison product'[ITEM_NAME] ),
                PurchasedBoth + ComparisonProduct
            )
        )

    If the above one can't help you, please provide some raw data in your table  'bm_retail_t product_file' and
    'Comparison product'
     
    with Text format and your expected result with backend logic and special examples. By the way, is there any relationship between these two tables? If yes, please provide the related info. It would be helpful to find out the solution. You can refer the following links to share the required info:

    How to provide sample data in the Power BI Forum

     

    And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

    How to upload PBI in Community

    Best Regards

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi abc_777 ,

    Please update the formula of measure [Purchased Both Products Quantity1] as below and check if it can return the expected result...

    Purchased Both Products Quantity1 =
    VAR PurchasedBoth = [Purchased Both Products Quantity]
    VAR ComparisonProduct = [Quantity Comparison Product]
    RETURN
        SUMX (
            VALUES ( 'bm_retail_t product_file'[ITEM_NAME] ),
            SUMX (
                VALUES ( 'Comparison product'[ITEM_NAME] ),
                PurchasedBoth + ComparisonProduct
            )
        )

    If the above one can't help you, please provide some raw data in your table  'bm_retail_t product_file' and
    'Comparison product'
     
    with Text format and your expected result with backend logic and special examples. By the way, is there any relationship between these two tables? If yes, please provide the related info. It would be helpful to find out the solution. You can refer the following links to share the required info:

    How to provide sample data in the Power BI Forum

     

    And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

    How to upload PBI in Community

    Best Regards