For a report on bakery product performance I am trying to match the purchase price with the selling price in order to get to a product margin. The purchase price sits in a separate table and so does the selling price. Both tables contain product numbers so I am able to merge the two queries in order to get both selling price and purchase price on one line in order to compute a product margin.
The difficulty however is the fact that the selling prices and purchase prices are very subjective to change. Each line in both tables has a date field that is changing often. Therefore I would like to merge the queries in such a way that the selling price of a given product is corresponding to the purchase price of the same product, but also make sure that the date of the selling price and purchase price align.
How would I go about and do this?
Tables would look like this:
DATE - SHOP - PRODUCTNR - QUANTITY SOLD - TOTAL SALES - SELLING PRICE PER PRODUCT
DATE - PRODUCTNR - PURCHASE PRICE PER PRODUCT
You need to add a new column consisting of the [PRODUCTNR] and [DATE] fields. You can use a simple concatenate operation to achieve this:
For Example:
Let's say you have such a table:
Then you need to create a new column called [CompositeKey] in the table:
CompositeKey =
[DATE] & "-" & [PRODUCTNR]
Resulting Table:
Note: I used (-) character to separate columns. You can use any others, like pipe(|), underscore(_) etc...
Now you need to do the same for your 2nd table, and create a relationship between your [CompositeKey] columns on both tables. Now It will adapt to changing dates, and you will know which is which... I hope It solves your problem.
Related
I have a REDSHIFT dataset which includes customer purchases as a SKU level.
I'm struggling to produce a view that includes multiple aggregates at a customer level. For example my table includes columns like: customer_id, order_id, product_id, product_category, product_division, sales, units
From this base I'd like a result which looks like
customer_id
total_sales (i.e. sum of all SKU sales)
total_units
total_orders
categories_purchased (i.e. a distinct count of categories the customer purchased)
divisions_purchased
primary_category_sales (i.e. category with the highest sales)
primary_division_sales
primary_category_mix (i.e. primary category sales / total sales)
primary_division_mix
While I can aggregate results for the whole dataset, I can't seem to crack how to incorporate sub-aggregates like finding the maximum category and its relative contribution to total sales. Any help you can offer is most appreciated!
I have tried nesting queries + using window functions but keep running into errors like aggregate function calls may not have nested aggregate or window functions.
I'm trying to calculate a simple sum of sales for different products but i have a visualization problem.
I have 2 different tables:
"Master data" where i can find all the informations about a porduct (product ID, description etc)
"total sales" where i can find for each product_ID the total sales amount
These tables are connected by a relationship based on the "product_ID".
I have created a table with product_ID (from "Master data") and total sales (from "total sales") but it returns the same amount of sales for every product ID (the sum of sales of all products)
Exemple:
product_ID_1 100€
product_ID_2 100€
product_ID_3 200€
I visualize the incorrect values like this:
product_ID_1 400€
product_ID_2 400€
product_ID_3 400€
Thanks in advance!!!
Ersilia
This is absolutely impossible!
If you put 'Master Data'[Product ID] next to [Sum Total Sales] in one table visual, then 'Master Data'[Product ID] will filter [Sum Total Sales].
If you see the Total of [Sum Total Sales] in every row, then YOU ARE NOT FILTERING, because you clearly don't have a relationship between 'Master Data' and 'Total Sales'. Check that in the Model view: The line is either missing, or dotted (inactive).
But with the given sample data from above you should have a one-to-one relationship between the Product ID's, although in general this will be a one-to-many relationship, since every product is probably sold more than once.
I'd recommend using more general sample data to check this out and not to use the same names for tables and their columns and esp. not 'Total' everywhere, so that you don't end up with such confusing expressions like "Total of [Sum Total Sales]". This is asking for trouble.
I have two tables which have counts and sales based on dates and one of them also have customer ID. The counts are not same when we see by customer and summary. I also have customer filter on my dashboard. What I want to achieve is if no customer is selected the count should come from summary table otherwise it should come from customer if multiple or one is selected in the filter.
Customer Table
Summary Table
Any hints, I have tried lookupvalue function but I cant put date as search value from date table.
It's much easier to use Measures, instead of creating calculated tables to obtain those metrics. Also, summarized tables would not have the same filter context your are looking for.
Measure 1
Total Customers =
DISTINCTCOUNT('Customer Table'[CustomerID])
Measure 2
Total Sales =
SUM ( 'Customer Table'[Sales])
I have merged two tabels ( sales and forecast ). For all the rows coming from sales query the cost price column has a value. The forecast rows does not have that.
In order to calculate future metrics/KPI I need to make a Power Query transformation that populates cost price on all forecast rows. I would like to do some kind of refence to the ProductName (exits both on the sales and forecast rows) and pull the cost price from the sales rows. The ProductName can have multiple entries in the table, but will be the same for alle the rows. So maybe a find first/max or something would be fine.
However, I am not sure have to make this calcuated column with some sort of lookup to ProductName?
Well you can definitely do so
Here is an excellent Article form Microsoft on LookupValue
In addition check this Thread as well. It will give you more Idea.
I would do something like
=LOOKUPVALUE(Product[SafetyStockLevel], [ProductName], " Mountain-400-W Silver, 46")
I am fairly new to PowerBI DAX and I want to filter out the top 20 product ids in a measure.
I came up with this formula but it does not seem to be working and I was hoping to get some help here.
$ Amount Parcel =
CALCULATE(
SUM(Data[$ Amount Parcel]),
FILTER (Data, NOT (Data[idProduct], SUM(Data[NetSales])) IN TOPN(20, SUMMARIZE(Data, Data[idProduct], "NetSales", SUM(Data[NetSales]))))
)
I want to show sales per PID for all products except for our 20 best sellers.
Thank you !!
I would suggest an easier approach adding a dimension column.
First of all, you need to have Product dimension table separated from Sales fact table. Make sure to create one-to-many relationship between Product and Sales with "Single" cross filter direction.
Then you can create a calculated column on Product table, which can be used to filter out top selling products.
Sales Rank = RANKX('Product', CALCULATE(SUM(Sales[SalesAmount])))
Now drag and drop Sales Rank field into the Filters pane of your visualization, and set the filter condition so that top selling products will not be shown.