Forum Discussion

GenZam1988's avatar
GenZam1988
Frequent Visitor
2 years ago
Solved

Price variation vs other

Hi can you helpme to solve this scenary in PB 

I need to compare the variation of product prices, always against the first product.

And show in a table like the example below

 

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi GenZam1988 ,

    Please try the following methods and check if they can solve your problem:

    1.Create the simple table.

    2.Create the new column to calculate. Drag the column into the table visual and select don’t summarize.

     

    Dif_price = 
    VAR price_1 = SUMX(FILTER('Table', 'Table'[Product] = "Product 1"),'Table'[Price])
    VAR dif_price = (DIVIDE('Table'[Price], price_1) - 1)
    RETURN
        IF(dif_price = 0, BLANK(), dif_price)

     

    3.Select percentage value and one number of decimal.

    4.The result is shown below.

    Best Regards,

    Wisdom Wu

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

     

     

     

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    You might find it difficult to get a good answer with such a minimal description.  The answer to your question will depend on how you have modelled your data.  How would an algorithm know what a "first" price is?  Do you flag in your dataset what is the first product?  Do you group your products in a manner so you can collate the first and others?  Is "first" something you expect to be a user choice field rather than something stored in the data?

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi GenZam1988 ,

    Please try the following methods and check if they can solve your problem:

    1.Create the simple table.

    2.Create the new column to calculate. Drag the column into the table visual and select don’t summarize.

     

    Dif_price = 
    VAR price_1 = SUMX(FILTER('Table', 'Table'[Product] = "Product 1"),'Table'[Price])
    VAR dif_price = (DIVIDE('Table'[Price], price_1) - 1)
    RETURN
        IF(dif_price = 0, BLANK(), dif_price)

     

    3.Select percentage value and one number of decimal.

    4.The result is shown below.

    Best Regards,

    Wisdom Wu

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.