How to create a total percentage calculated field over specific fields?

Hello,

I need to create a calculated field to show the percentage per day between two product categories in a table.

My calculated field “products”:

switch(product,
“A”, “blablabla 1”,
“B”, “blablabla 2”,
“C”, “Product 1”,
“D”, “Product 2”,
“E”, “blablabla 3”,
“F”, Product 2",
“G”, Product 2",
“H”, “Product 1”,
“I”, “blablabla 4”,
“Others”
)

In the “products” field there are several products, but I need to consider only the products “Product 1” and “Product 2” and the sum of the percentage between these two products must be 100%.

Sales quantity of products “Product 1” and “Product 2”

sumProduct1_2:
sumif(quantity_unique_sales, product in (“Product1”, “Product 2”)

How do I create a calculated field that shows the percentage of two products, considering the sum of these products to be 100% ?

I tried to create the field with PercentOfTotal, but it didn’t work.

Output I need:

                 14/Jun  15/Jun.........

Product 1 27% 46%
Product 2 73% 54%

Any ideia?

Thank you so much.
July.

Do you have sums already calculated for those products?

For product 1 would it be: {product_1}/({product_1} + {product_2})
For product 2 would it be: {product_2}/({product_1} + {product_2})

Is that what you’re looking for?

1 Like

Hi,

The percentOfTotal works if I consider only one day, but when put some days, the percentage distributes between the other dates.
I need to consider always 100% per day from both categories.
How to do that?
Thanks

percentOfTotal(sum( {quantity_unique_sales} ) )

image

image

I think I need to fixed the percent total per day, but I don´t know how to do that.

You should be able to partition by day.

percentOfTotal
(
     measure 
     ,[ truncDate('DD',{date} ]
)
1 Like

Wow!
It´s working now!

Thank you so much, @Max.