I have two separate tables that are used to calculate total savings of repaired products.
Table_A is a result of my SQL Server query and contains information about all repairs performed on specific products:
Timestamp
Product_serialnumber
Product_name
Repair_reference
Repair_description
2022-10-02 11:52:36.330
Serial_A
Product_A
J1
Damaged
2022-10-02 11:52:37.343
Serial_A
Product_A
J3
Damaged
2022-10-02 11:52:37.720
Serial_A
Product_A
P5
Bent
2022-10-20 03:02:11.713
Serial_B
Product_A
J8
Dirty
2022-10-20 03:03:45.570
Serial_C
Product_B
P40
Damaged
2022-10-20 23:49:54.837
Serial_D
Product_C
P8
Dirty
2022-11-12 08:26:11.270
Serial_E
Product_A
J50
Bent
One Product_serialnumber can be repaired many times.
Table_B is very simple and created manually - it contains information how much each unit of specific product is worth.
Product_name
Value
Product_A
250
Product_B
250
Product_C
175
Both tables are joined with many to one cardinality with single cross filter direction running from Table_B to Table_A.
My task was to create visual to show how many Product_serialnumber s were repaired and how much we saved by repairing them. It is very important to perform DISTINCTCOUNT of Product_serialnumber , not COUNT of all repairs performed on them as 3 repairs on 1 Product_serialnumber worth 250 is still 250 saved, not 750.
In PowerBI I have one table with summary. To calculate savings I created following DAX measure in Table_A:
Measure = DISTINCTCOUNT('Table_A'[Product_serialnumber]) * MAX(Table_B[Value])
It gave me results below:
Product_name
Distinct count of Product_serialnumber
Value
Savings
Product_A
3
250
750
Product_B
10
250
2500
Product_C
25
175
4375
Total
38
9500
Each row has correct Savings value but Total is wrong. Instead of 9500, there should be 7625.
I figured out that MAX(Table_B[Value]) in my DAX Measure simulates 38*250. When I changed that to MIN, it was 38*175. So still wrong
To correct that, what I eventually did was I created New Column in Table_A:
RELATED_Value_from_table_b = RELATED(Table_B[Value])
Now each row in Table_A has correct Value based on Product_name.
Only then I created this measure in Table_A:
Saved = SUMX(
DISTINCT('Table_A'[Product_serialnumber]),
CALCULATE(MAX('Table_A'[RELATED_Value_from_table_b])))
So I got following result:
Product_name
Distinct count of Product_serialnumber
Value
Savings
Product_A
3
250
750
Product_B
10
250
2500
Product_C
25
175
4375
Total
38
7625
Total is finally correct.
Of course I found the solution to the task but I am not happy of how I did it and I believe there is more optimized way of doing it. I want to know it to be better in the future.
Date:
Customer
Sales
User
Last Order
Order Sent
1001
abc
1001
afe
1001
wr3
1002
avc
1/1/2021
Yes
1002
abc
1003
abc
1/1/2021
Yes
I have the table above and I need a "Dax formula" that will label the Sales as yes for all users for each customer if the last order has a date value in it. or order sent is Yes, I'm open to either.
When I can make a filter that would show if that one line has an order but I need help making the entire customer for sales if they have placed an order.
If this is the desired result, you can calculate Sales using a measure like this:
Sales = CALCULATE(
MAX(Customers[Order Sent]),
ALLEXCEPT(Customers,Customers[Customer]))
This video is a good example of how to calculate the max within a group using a measure.
I have a table of sales from multiple stores with the value of sales in dollars and the date and the corresponding store.
In another table I have the store name and the expected sales amount of each store.
I want to create a column in the main first table that evaluates the efficiency of sales based on the other table..
In other words, if store B made 500 sales today, I want to check with lookup table to see the target then use it to divide and obtain the efficiency then graph the efficiency of each store.
Thanks.
I tried creating some measures and columns but stuck with circular dependencies
I expect to add one column to my main table to an integer 0 to 100 showing the efficiency.
You can merge the two tables. In the query editor go to Merge Querires > Merge Query As New. Chose your relationship (match it by the column StoreName) and merge the two tables. You will get something like this (just a few of your sample data):
StoreName ActualSaleAmount ExpectedAmount
a 500 3000
a 450 3000
b 370 3500
c 400 5000
Now you can add a calculated column with your efficency:
StoreName ActualSaleAmount ExpectedAmount Efficency
a 500 3000 500/3000
a 450 3000 450/3000
b 370 3500 370/3500
c 400 5000 400/5000
This would be:
Efficency = [ActualSaleAmount] / [ExpectedAmount]
Good day. I am looking for a way to group the table below per day and count ID's using a measure, in order to be able to get max count, min count, percentile etc..
Date ID
2018-01-01 ABC
2018-01-01 DEF
2018-01-01 GHI
2018-01-02 JKL
2018-01-02 MNO
2018-01-03 PQR
2018-01-03 STU
2018-01-03 VWX
I can create a table like that using:
group_by_count = SUMMARIZE(Table1;Table1[Date];"count";COUNTROWS(Table1))
Date count
2018-01-01 00:00:00 3
2018-01-02 00:00:00 2
2018-01-03 00:00:00 3
However, I don't want an extra table in my report as my real data contains some years of data and other interesting columns I will filter on. Any ideas how to go about to do this, using only measures?
Further clarification:
My end goal is to get a measure that, for example, returns the max count. With my example data that would be 3. I will use this measure in cards and build dynamic texts for cards. Then I could build a text that says for example: "The maximum number of events in one day was 3".
You don't need to actually create a new table. You can use the SUMMARIZE function within a measure. For example,
MaxCount = MAXX(SUMMARIZE(Table1; Table1[Date]; "Count"; COUNT(Table1[ID])); [Count])
I have this deadline in the next few hours and I would really appreciate your help.
I need to create a formula to calculate buyer premium fees from the hammer price at an auction.
It works like this.
The hammer price is = X
Tax1 £0-£100,000 = 25% (Every sale is charged 25% up to the value of £100,000 so max is £125,000 for this part)
Tax2 £100,000-£2,000,000 = 20% If the hammer price exceeds £100,000, then 20% is added for this portion.
Tax3 £2,000,000+ = 12%. If the hammer price exceeds £2,000,000, then 12% is added to this portion.
Could anyone help me create a formula that would allow me to enter the hammer price and it would auto-calculate the total fees and give me the total price including those 3 taxes.
The code I have so far is this:
Tax 1 = IF(B3<=100000,B3*0.25,100000*1.25)
Tax 2 = IF(B3<1900000,B3*0.2,1900000*0.2)
Tax 3 = (B3-2000000)*0.12
You can use simple if statement for the same
Please refer to the formula in the address bar below.
Breaking this down into smaller chunks
Cost less than 100k, 25%, otherwise 25% of 100k
=IF(A1<10000,A1*0.25,25000)
Cost over 100k but less than 2m, 20% of the portion between 100k and 2m + the 25% of 100k
+IF(AND(A1<2000000,A1>=100000),(A1-100000)*0.2,(IF(A1<100000,0,40000)))
Cost over 2m, 12% of the portion over 2m plus the previous chunks+IF(A1>2000000,(A1-2000000)*0.12,(IF(A1<2000000,0,65000)))
Putting it all together
=IF(A1<10000,A1*0.25,25000)+IF(AND(A1<2000000,A1>=100000),(A1-100000)*0.2,(IF(A1<100000,0,40000)))+IF(A1>2000000,(A1-2000000)*0.12,(IF(A1<2000000,0,65000)))
Few test cases
* Hammer Commission
* 0 0
* 10 2.5
* 100000 25000
* 100001 25000.2
* 2000000 130000
you can try this one which conforms to your conditions:
=IF(B3<=100000,B3*0.25,IF(AND(B3>100000,B3<=2000000),B3*0.2,IF(B3>2000000,B3*0.12,"NOT FOUND")))
Please confirm if below calculation for hammer price £500,000 are correct.
See below screenshot for functions used:
I'm still trying to share excel file with you. Can't upload here!!!
Excel file with required functions. See instructions to change Hammer Price in file.
Hammer Price Excel File