Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hello, I am trying to make an annual sales column chart that shows how much we sold throughout the year, thats pretty standard for a simple table, however we get from our client a table comprising of all the sales they made and this chart computes only items produced by us and along the year we release new items that must be shifted from produced by a 3rd party or produced by us.
Client sales table example
Sales Table | ||
sale date | productid | net sale |
s1 | p1 | $$ |
s2 | p2 | $$$ |
s3 | p3 | $$$$ |
s4 | p4 | $$ |
s5 | p5 | $ |
s6 | p6 | $$ |
To do so we use a flag column to mark the items produced by us and use that as a filter in calculate function to get the function to compute only our sales and give us a measure that is used in the chart. But that way if a product is released lets say in july, changing this flag will make the function consider that product being ours since forever... so it will be computed as well in the previous months.
Our product identification table
Product Table | ||
productid | pname | Own brand |
p1 | pname1 | 1 |
p2 | pname2 | 1 |
p3 | pname3 | 1 |
p4 | pname4 | 0 |
p5 | pname5 | 1 |
p6 | pname6 | 1 |
What I ve been trying to do without success is to make the measure add those products based on the month they were launched under our own brand by using another flag and a column that shows when a new item was added. (so the item is the same, ie. if p2 was a milk carton and we started producing it it would still count in their system as a milk carton and therefore as p2 but produced by us, and they would take the other brand off the shelfs so all sales past this date would be considered ours.)
To do so I added 2 new columns that show if the item is new and wich date it was introduced
Product Table | ||||
productid | pname | Own brand | new product flag | sales date beginning |
p1 | pname1 | 1 | 0 | - |
p2 | pname2 | 1 | 1 | jul/20 |
p3 | pname3 | 1 | 1 | jul/20 |
p4 | pname4 | 0 | 0 | - |
p5 | pname5 | 1 | 0 | - |
p6 | pname6 | 1 | 1 | nov/20 |
the original measure is
Solved! Go to Solution.
Hi @Anonymous ,
Based on the information you gave believe you need to do the following measures:
Sales Own brand = CALCULATE(SUM(Sales[Quantity]), products[Own brand] = 1 ,products[new product flag] = 0)
Sales Other Brands = CALCULATE(SUM(Sales[Quantity]), products[Own brand] = 0 )
Sales Other Brands (before date of own brand) =
SUMX (
FILTER (
CROSSJOIN (
products,
SUMMARIZE ( sales, Sales[Product], Sales[Quantity], Sales[Sale ID] )
),
Sales[Sale ID] < products[sales date beginning]
&& products[new product flag] = 1
&& products[Own brand] = 1
&& products[productid] = Sales[Product]
),
[Quantity]
)
Sales Own Brands (after date of own brand) =
SUMX (
FILTER (
CROSSJOIN (
products,
SUMMARIZE ( sales, Sales[Product], Sales[Quantity], Sales[Sale ID] )
),
Sales[Sale ID] >= products[sales date beginning]
&& products[new product flag] = 1
&& products[Own brand] = 1
&& products[productid] = Sales[Product]
),
[Quantity]
)
Others = [Sales Other Brands] + [Sales Other Brands (before date of own brand)]
Own Brad = [Sales Own brand] + [Sales Own Brands (after date of own brand)]
The last two measure are the ones you need to use on your visualization I just broke it down in 4 measures in order to check the results more accurralty and if needed to be easier to edit the own / other brands part.
Check result in attach PBIX file attach,
Data is:
Has you can see in January until July (when the first item passes to own brand) sales are 1 for own and 3 for other in July to November we have 2 of each after november the chart flips and you get 3 own and 1 others.
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsHi @Anonymous ,
Based on the information you gave believe you need to do the following measures:
Sales Own brand = CALCULATE(SUM(Sales[Quantity]), products[Own brand] = 1 ,products[new product flag] = 0)
Sales Other Brands = CALCULATE(SUM(Sales[Quantity]), products[Own brand] = 0 )
Sales Other Brands (before date of own brand) =
SUMX (
FILTER (
CROSSJOIN (
products,
SUMMARIZE ( sales, Sales[Product], Sales[Quantity], Sales[Sale ID] )
),
Sales[Sale ID] < products[sales date beginning]
&& products[new product flag] = 1
&& products[Own brand] = 1
&& products[productid] = Sales[Product]
),
[Quantity]
)
Sales Own Brands (after date of own brand) =
SUMX (
FILTER (
CROSSJOIN (
products,
SUMMARIZE ( sales, Sales[Product], Sales[Quantity], Sales[Sale ID] )
),
Sales[Sale ID] >= products[sales date beginning]
&& products[new product flag] = 1
&& products[Own brand] = 1
&& products[productid] = Sales[Product]
),
[Quantity]
)
Others = [Sales Other Brands] + [Sales Other Brands (before date of own brand)]
Own Brad = [Sales Own brand] + [Sales Own Brands (after date of own brand)]
The last two measure are the ones you need to use on your visualization I just broke it down in 4 measures in order to check the results more accurralty and if needed to be easier to edit the own / other brands part.
Check result in attach PBIX file attach,
Data is:
Has you can see in January until July (when the first item passes to own brand) sales are 1 for own and 3 for other in July to November we have 2 of each after november the chart flips and you get 3 own and 1 others.
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsOmg, thats it ! thank you so much !
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
109 | |
96 | |
77 | |
66 | |
53 |
User | Count |
---|---|
144 | |
105 | |
102 | |
89 | |
63 |