Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago

Product Profit Bucketing By Color

Hi All,

 

We have a requirement in our project, i just replicated the sccenario using AdventureworksDB.

 

sample data:

 

https://jobatfresheronline-my.sharepoint.com/:x:/g/personal/admin_jobatfresheronline_onmicrosoft_com/Ebgs0-8B8qpBgplNdORn5r8BETBPXlPgoPz3ug4HZXMMhQ?e=122TGL

 

expected visual output:

https://jobatfresheronline-my.sharepoint.com/:i:/g/personal/admin_jobatfresheronline_onmicrosoft_com/EcMHpMYs7EZNlctBys2ibaQBsPj5z_vkpdq8Kt8Hlj66Vg?e=V0rCoC

 

 

we have to calculate the number of products, which difference between sales and cost is >200000 ,

difference between sales and cost is <200000 and >100000

and <100000

 

 

Thanks..

12 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi,

    Is the result image displaying the correct numbers or it is just an example?

    Here's what i got:

    Thanks.

  • Hi, I think there are several ways to do this.

     

    In case you are looking this validation row by row, I mean checking the difference on each row, the most common is to add a new column with two if conditions asking for the range values and the return will be text categorizing this three possibilities. This column can be created in Power Query or DAX. And easty way to categorize values is creating a group, example.

    Then you can add this new column as legend in your visualization and a distinct count of productkey as values.

     

    In case you want to check the difference in all sales of the product then you should create three measures, one by each range and use three values and no legend. Like this:

    COUNTROWS (
        FILTER (
            ADDCOLUMNS (
                SUMMARIZE ( Table, Table[ProductKey] ),
                "Difference", SUM ( Table[Sales] ) - SUM ( Table[Cost] )
            ),
            [Difference] > 200000
        )
    )

    Hope one of this helps

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