The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hi, I could really use some help with the following calculation. let's say we have different categories with both fixed and variable pricing for our customers, based on the package they're in and the number of users our customers have.
For a 'small customer' the price would be 25USD for up to 10 users, + 2 for every additional (over 10) user.
For a 'medium customer'the price would be 50USD for up to 25 users, + 1,50 for every additional (over 25 users)
We'd have these columns:
Customer, CustomerType, UserAmount, Price (expected results)
Customer1, Small Customer, 8, 25 (Just the package price (small))
Customer2, Small Customer, 12, 29 (package price (25) + 4 (2 additional users)
Customer 3, Medium Customer, 6, 50 (Package price (medium)
Customer 4, Medium Customer, 35, 65 (Package Price medium + 10 additional users (+1,50)
So the customers pay for the package they choose and will have to pay an extra amount if they end up having more users than currently are in the platform.
How do I calculate this Price column? If possible I'd also like the calculation to include a filter based on CustomerType, because customers could be in customer types, regardless of the amount of users.
Thanks in advance,
Justin
@Anonymous
Try something like this
Price =
VAR __CustomerType = 'MyTable'[ CustomerType]
VAR __UserAmount = 'MyTable'[ UserAmount]
VAR __SmallCustomer =
IF (
__CustomerType = "Small Customer",
IF ( __UserAmount <= 10, 25, ( ( __UserAmount - 10 ) * 2 ) + 25 )
)
VAR __MediumCustomer =
IF (
__CustomerType = "Medium Customer",
IF ( __UserAmount <= 25, 50, ( ( __UserAmount - 25 ) * 1.5 ) + 50 )
)
VAR __finalresult =
SWITCH (
__CustomerType,
"Small Customer", __SmallCustomer,
"Medium Customer", __MediumCustomer
)
RETURN
__finalresult
Did I answer your question? Mark my post as a solution!
Appreciate with a kudos 🙂
@Anonymous
Another option using DATATABLE.
Price =
VAR __table =
DATATABLE (
"Type", STRING,
"Limit", INTEGER,
"Amount", CURRENCY,
"Extra", DOUBLE,
{
{ "Small Customer", 10, 25, 2 },
{ "Medium Customer", 25, 50, 1.5 }
}
)
VAR __CustomerType = 'MyTable'[ CustomerType]
VAR __UserAmount = 'MyTable'[ UserAmount]
VAR __Limit =
MAXX ( FILTER ( __table, [Type] = __CustomerType ), [Limit] )
VAR __Amount =
MAXX ( FILTER ( __table, [Type] = __CustomerType ), [Amount] )
VAR __Extra =
MAXX ( FILTER ( __table, [Type] = __CustomerType ), [Extra] )
VAR __Result =
IF (
__UserAmount <= __Limit,
__Amount,
__Amount + ( ( __UserAmount - __Limit ) * __Extra )
)
RETURN
__Result
Did I answer your question? Mark my post as a solution!
Appreciate with a kudos 🙂
Hi @Anonymous ,
Create a Calculated Column
Column =
SWITCH(
TRUE(),
'Table (2)'[Customer Type] = "Small Customer" && 'Table (2)'[User Amount] <=10 , 25,
'Table (2)'[Customer Type] = "Small Customer" && 'Table (2)'[User Amount] >10 , 25 + (('Table (2)'[User Amount] - 10) * 2),
'Table (2)'[Customer Type] = "Medium Customer" && 'Table (2)'[User Amount] <=25 , 50,
'Table (2)'[Customer Type] = "Medium Customer" && 'Table (2)'[User Amount] > 25 , 50 + (('Table (2)'[User Amount] - 25) * 1.5)
)
Regards,
Harsh Nathani
Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)
Hi @Anonymous ,
Please share some sample data in text format and the expected output.
Regards,
Harsh Nathani
Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)
User | Count |
---|---|
28 | |
12 | |
8 | |
7 | |
5 |
User | Count |
---|---|
36 | |
14 | |
12 | |
7 | |
7 |