Calculating total daily sales orders in PowerBI using DAX - powerbi

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

Related

DAX Measure Calculation Two Different Tables

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]
)

COUNT number of week with specific value ranges

I have a report that shows me the sales for each department for the current year. This is visualized in a matrix with.
The sales table contains a date column that is linked to a simple calendar table that contains information like week, month, year etc.
Now I would like to count the number of weeks where
Strong = Sales above 500k
Extraordinary = Sales above 750k
Moderate = Sales below 500k
How is this possible by using a DAX Measures?
Hopefully this works without sample data because I right now have just access to my cell phone.

Using RANKX with a YTD Measure does not rank correctly

I am trying to calculate the Cumulative Purchases by YTD. The first step is to rank the items by Cost Amount, but when I try to rank by the [_YTD Cost] measure, the numbers I get do not make sense (skipped numbers, duplicated).
[]
I had 3 slicers: Month, Year and to select Month/YTD measures. Since with the Month calculation I have no problems, I removed the interaction with the Month/YTD slicer and I placed only YTD measures on the table:
Total Purchase Cost = SUM ( Purchases[Amount] )
_YTD Cost = TOTALYTD([Total Purchase Cost], 'dim-calendar'[Date])
_RANK YTD = RANKX(ALLSELECTED(Purchases), [_YTD Cost])
Notes:
I pulled the item from the Item table
The Purchase table is linked to the Date table by Purchase Date
Not 100 % sure on your data model, but try changing your RANKX(ALLSELECTED(***) to reference the Item-column. Like this:
RANKX(ALLSELECTED('Item'[Item]), [_YTD Cost])

DAX TopN Behavior

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

How can I measure Number of Items with over X amount of sales?

I have a Power BI database set up as follows:
Sales[Date] is the date in which the sale took place. Sales[ProductID] is the SKU, while Sales[Units] is the number of units sold per SKU. I have also added a measure to calculate the total # of units sold. I am trying to set up a distinct count of SKUs where more than 500 SKUs were sold. I am using the following formula:
SKUsWith500Sales = CALCULATE(DISTINCTCOUNT(Sales[ProductID]),FILTER(Sales,[TotalUnits]>=500))
The output is either blank or inaccurate.
Thank you!