I have one question about DAX calculation?
Hi Guys,
I have one question about DAX Measure Calculation
Please Help me get the solution of this problem
I have 2 tables
table 1 - Purchase Info
(Column name - Customer ID, Product ID, Quantity, Payment Mode)
table 2 - Product Info
(Column name - Product ID, Product Name, Product Cost, Selling Cost, Tax Amount)
My Question Is, How to Calculate Total Revenue?
The Table 1 (Purchase Info) have repeated customers and more than 10 thousand of records and also records are shuffled. The table 2 (Product Info) have only 10 products and unique records ( Product ID). How to calculate the total revenue.
This will work if you linked your tables via Product ID.
SUMX(
Prod
,CALCULATE(SUMX(Sales,Sales[Quantity]))*Prod[Selling Cost]
)
Related
I am trying to get the total number of sales orders received daily. This will be sum of sales orders received + sum of sales shipments. Note that sales shipment has unique sales order number as well. There could be multiple sales shipments for 1 sales order, thus creating an error.
I am currently using:
Sales orders received = DISTINCTCOUNT (salesOrders[number]) + DISTINCTCOUNT(salesShipments[orderNumber]))
But this gives wrong number as sales order number can be in sales order table and sales shipment table both.
All I want is the distinct count of sales order numbers in Sales order table and Sales shipment table.
Any help is highly appreciated.
thank you
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.
Power BI newbie here and I'm trying to figure how to craft my DAX to manipulate my measure values based on certain criteria in the other two tables.
Currently I have 2 separate tables which are joined by a One to Many relationship and a separate Measures table. (Total Sales Price is computed as sum of Sales Price)
My aim is to create a new measure where Total Sales Price is multiplied by 1.5x when DIM_Product_Type[Product Category] = "High".
New Measure =
CALCULATE (
SUM ( FACT_PriceDetails[Sales Price] ),
FILTER ( DIM_Product_Type, DIM_Product_Type[Product Category] = "High" )
) * 1.5
However this returns no values in my visual and I'm trying to discern if its a matter of the table joins or the DAX expressions.
Thank you for your time!
Your measure seems good.
It will select only those products with a Product Category of "High" and multiply them by 1.5 to give you result. i.e. Give me the sum of all "High" Product category Price details multiplied by 1.5.
What you need to check is:
Product Serial Numbers match across the two tables
Your Product Category does indeed contain the category "High"
You have entries in FACT_PriceDetails that link to a DIM_Product_Type that has a category of "High"
Check you have not set any filters that could be hijacking your results (e.g. excluding the "High" product category product type or the realated fact/s)
Option-1
You can do some Transformation in Power Query Editor to create a new column new sales price with applying conditions as stated below-
First, Merge you Dim and Fact table and bring the Product Category value to your Fact table as below-
You have Product Category value in each row after expanding the Table after merge. Now create a custom column as shown below-
Finally, you can go to your report and create your Total Sales measure using the new column new sales price
Option-2
You can also archive the same using DAX as stated below-
First, create a Custom Column as below-
sales amount new =
if(
RELATED(dim_product_type[product category]) = "High",
fact_pricedetails[sales price] * 1.5,
fact_pricedetails[sales price]
)
Now create your Total Sales Amount measure as below-
total_sales_amount = SUM(fact_pricedetails[sales amount new])
For both above case, you will get the same output.
Just wanted to confirm my understanding (or lack thereof) around these two formulas - in an orders table where each row is an order:
TOPN(10,ALL(Orders),[Total Sales]) - looks at the individual Sales amount for each row and returns the whole table with just the top 10 records sorted by the Sales field; using the measure Total Sales(defined as Sum of Sales) in this context doesn't really have an effect as the aggregation is at a single row level which just keeps it the same.
TOPN(10,ALL(Orders[Customer Name]),[Total Sales]) - this actually groups by the customer name, calculates the total sales, and returns the top 10 customer names based on that metric; it's more or less equivalent to this SQL:
select customer_name, sum(sales) as Total_Sales from orders
group by customer_name
order by Total_Sales desc
limit 10
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.