We have an online shop running opencart 1.5.6.4 and hoping to figure out a way of round the prices to the nearest .99. We just switched on "show prices with vat" and all our prices are now up 23%. I was hoping I could get the pricing looking a little bit better
For example:
Current Price: €608.85
New Price: €608.99
If there was a way of editing the table "product" and incrementing all the "price" values to end with .99, it would be really really helpful :-)
Thanks
You can round up using ceil and then subtract a cent:
select ceil(2.20) - 0.01
In an update, you can do this:
update product
set
price = ceil(price) - 0.01
Instead of ceil you can also select round, to round to the nearest whole number or floor to always round down. But beware: products that were, say, 0.20 will become -0.01 then.
If you only want to display nicely rounded prices in vat, but store them ex vat, then you'll have to do a calculation for that.
(Crooked indenting to be able to squeeze comments in)
update product
set
price =
round(
-- Calculate the price incl VAT. Round it, and subtract a cent
ceil(price * 1.23) - 0.01
-- Round to whole cents.
, 2 )
-- Divide to calculate the price excluding VAT that belongs to the rounded price.
/ 1.23
Related
It wont be possible to share my data.
I've a lot of purchasing information with purchasing day, supplier, delivery value and quantity.
When I try to summarize it to get an average price per unit (Value / quantity), my calculations goes crazy.
Sometime delivered quantity for all deliveries haven't been registered, that results in "NaN". So i've been using a powerQuery to avoid that.
Formula: = if [Delivered Quantity] = 0 then 0 else [Delivered Value]/[Delivered Quantity]
Below is a picture of my problem, as you can see the "price per unit" is WAY to big.
Even if I delete the above formula and only use [Delivered Value]/[Delivered Quantity] and hide inifinity/NaN in filter, it still get some errors.
tried using an DAX formula:
avg price =
sum('Sum Tbl'[Delivered Value]) / sum('Sum Tbl'[Delivered Quantity])
and it worked.
I am attempting to pull a single value by using LOOKUPVALUE and it is doing so, but instead of returning the value, which is a decimal, it is rounding up to the nearest whole number.
Here's the code that I've tried and and example table of my data set.
Measure =
LOOKUPVALUE(
'Monthly Values'[Requested Value],
[Month Num],
MONTH(TODAY())
)
To be clear, [Month Num] is the Month in numerical form so January = 1, Feb. = 2, etc.
Here is an example table:
Month Irrelevant Month Num Requested Value
1/1/2019 6584651 1 2.48
2/1/2019 6516516 2 2.36
3/1/2019 3464 3 3.32
4/1/2019 6584814 4 2.72
Requested Value is formatted as a "Decimal Number" and limited to 2 decimal places. Also before someone asks, I have double checked the Measure to ensure the measure's formatting is also set to "Decimal Number" with 2 decimal places.
For this case the month is 4 and the formula should spit out "2.72" but instead is spitting out "3".
Is there a way to get around the rounding with LOOKUPVALUE? Alternatively is there another way to lookup this value which would not round the returning value?
I just had the same problem. What I did was to change the data type to decimal in the Power Query, then load the data to Data model (simply refresh the data).
Mine is fixed now.
Use following dax
Measure = FIXED(
LOOKUPVALUE(
'Monthly Values'[Requested Value],[Month Num],MONTH(TODAY())
),
2)
I am trying to set up ScoreCategory for every Salesman by Sales vs. average Sales.
Basic measures are correct.
For ScoreCategory I did these measures:
Average Production per ALL Sellers = CALCULATE([Sales YTD (2019)]/[Number of Sellers];ALL('ProductionTable'[Sellers_ID];'ProductionTable'[Sellers_Manager];'ProductionTable'[Region]))
and
Average Production per Seller = [Sales YTD (2019)]/[Number of Sellers]
and
Sales vs average = ([Average Production per Seller]/[Average Production per ALL Sellers])
Next step:
Scoring round up = ROUNDUP([Sales vs average];1)
While everything was fine.But when I tried to set up ScoringCategory like below, It shows me different, incorrect value in Table but in Total or in Card after filtering on one Seller it shows me right value of ScoringCategory.
ScoringCategory =
IF(OR([Scoring round up] = 0,0;[Scoring round up] = 0,1) ; 1;
IF(OR([Scoring round up] = 0,2;[Scoring round up] = 0,3) ; 2;
IF(OR([Scoring round up] = 0,4;[Scoring round up] = 0,5) ; 3;
IF(OR([Scoring round up] = 0,6;[Scoring round up] = 0,7) ; 4;
IF(OR([Scoring round up] = 0,8;[Scoring round up] = 0,9) ; 5;
IF(OR([Scoring round up] = 1;[Scoring round up] = 1,1) ; 6;7))))))
Please notice the different value for ScoringCategory calculated by "IF".
enter image description here
And when I filter on individual Seller
Differenc of ScoringCategory between Table and Card
Somewhere "IF" calculated right ScoringCategory, but somewhere it doesnt.
enter image description here
I Notice, that when ScoringCategory contain only 2 "IF functions" it calculated correct way, but When it contain more "IF function" like above, it is wrong.
Did anyone have a similar problem? Is there a different way for calculate ScoringCategory without "IF function"? I tried to use the interval with IF functions, but it didnt help...
I think it could work with a new interval table.
Something like this below, but I'm not sufficiently experienced to be able to adjust it to my solution.
TEST= VAR RankingDimension = VALUES('ProductionTable'[Sellers_ID]) RETURN CALCULATE([Sales vs average];
FILTER(RankingDimension;
COUNTROWS(
FILTER('Support Scoring';
RANKX(ALL('ProductionTable'[Sellers_ID]);[Sales vs average];;DESC)>'Support Scoring'[Min]
&& RANKX(ALL('ProductionTable'[Sellers_ID]);[Sales vs average];;DESC)<= 'Support Scoring'[Max]))>0))
I figured out, where was problem. So for others, Who are looking for answer.
Problem was in function ALL in this measure:
Average Production per ALL Sellers = CALCULATE([Sales YTD (2019)]/[Number of Sellers];ALL('ProductionTable'[Sellers_ID];'ProductionTable'[Sellers_Manager];'ProductionTable'[Region]))
I had to apply this function (ALL) to early calculation for measures Sales YTD (2019) and Number of Sellers
I have a NPV calculation which I've done manually because the XNPV function doesn't seem to work.
The NPV measure I've created looks like this:
'Data'[Undiscounted Value] / (1+'Discount Rate'[Discount Rate Value])^([Component]/12)
I've discovered the error with my calculation lies in the [Component] portion of the measure. The [Component] calculation is as follows:
IF(TODAY() > LASTDATE('Data'[Date]), BLANK(),
DATEDIFF(TODAY(), LASTDATE('Data'[Date]), MONTH))
The [Component] calculation is intended to determine the number of months for the NPV calculation. I'm dividing by 12 because I have an annual discount rate, but my data is in months.
The above calculation works perfectly in a line/bar chart. I have spot tested the months to confirm that the values are correctly discounted.
The PROBLEM occurs when I attempt to AGGREGATE the data. In other words, it works fine in a line chart, but when I just put the calculation on a card visual it uses the LASTDATE for the component and performs the calculation using the sum of all undiscounted values. In other words, it does something like this:
SUM ('Data'[Undiscounted Value] ) / (1+'Discount Rate'[Discount Rate Value])^(MAX(Component) /12)
and then spits out a result which is incorrect.
What it is supposed to be doing is simply taking the sum of all the discounted values. So running the calculation month by month and then adding all the months, but instead it's adding the Undiscounted values and then discounting them over 36 months.
My QUESTion is: is there an alternative function that would tell PowerBI not to use the LASTDATE, but instead iterate over each month (row) and then SUM
I would suggest the following solution structure:
SUMX(
VALUES( 'Data'[Month] )
, CALCULATE( NPV )
)
This will calculate the discount for each month before summing them up.
You may have to adjust your [Component] formula as well.
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