Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.
I'm trying to perform a calculation that will render costs charged by multiple vendors across multiple products and then get a grand total. Maybe I'm trying to do too much up front, but here's where I'm at so far. Table A is Vendor, and I'm trying to do calculations either in a statement or another table. Sorry for the mess in advance. Trying to figure out how to make it all work.
Vendor A charges 4 different amounts based on threshold:
Vendor | product | amount | threshold |
jim | apples | .10 | <20 |
jim | apples | .09 | >=21 & < 40 |
jim | apples | .08 | >= 41 & < 60 |
jim | apples | .07 | >61 |
jim | oranges | .10 | <20 |
jim | oranges | .09 | >=21 & < 40 |
jim | oranges | .08 | >= 41 & < 60 |
jim | oranges | .07 | >61 |
There are 2 vendors that have different prices for the 2 products and 3 vendors that have a combined rate. All vendors have different thresholds and prices. I've been trying to write a Switch ( True () ) measure to solve this, but am not having much luck. here's my attempt at getting this to work for a single vendor. After I've done that, I'll expand the statement to work for the rest.
Solved! Go to Solution.
@aharon0414 - I usually do not see calculate statements in a SWITCH(TRUE()...) statement. SWITCH is usually like:
SWITCH(TRUE(),
'Vendor'[VENDORNAME] = "jim" && 'Vendor'[Vendor Billable] > 300000, <some calc>,
'Vendor'[VENDORNAME] = "jim" && 'Vendor'[Vendor Billable] > 150000, <some calc>,
<some calc>
)
@Anonymous , Switch true will work but i doubt syntax you use refer example
Switch([age_group]
, "AgeGRoup_0-4" , 1
, "AgeGroup_5-9" , 2
, "AgegRoup_10-14" ,3
, "AgegRoup_15-19" , 4
, "AgegRoup_20-24" , 5
, "AgegRoup_25-29" , 6
7
)
or
Switch([age_group]
, "AgeGRoup_0-4" && [ABC] =4 || [def] =4 , 1
, "AgeGroup_5-9" , 2
, "AgegRoup_10-14" ,3
, "AgegRoup_15-19" , 4
, "AgegRoup_20-24" , 5
, "AgegRoup_25-29" , 6
7
)
@aharon0414 - I usually do not see calculate statements in a SWITCH(TRUE()...) statement. SWITCH is usually like:
SWITCH(TRUE(),
'Vendor'[VENDORNAME] = "jim" && 'Vendor'[Vendor Billable] > 300000, <some calc>,
'Vendor'[VENDORNAME] = "jim" && 'Vendor'[Vendor Billable] > 150000, <some calc>,
<some calc>
)
Thank you @Greg_Deckler !
That seemed to get me a step forward. SWITCH (True) ) is working now, but in my variables, it will only calculate based on the first variables created. My variables all reference another variable that transitions the context between respective vendors, but that is not carrying forward in the totality of the SWITCH statement. I'll try to work up a mockup to share, but for now, my data is confidential and it may be a lot of work to put something together.
@Anonymous it can be easily achieved by measures, if you put sample data in pbix file, it will help and I don't think SWITCH is the answer here, I could be totally wrong.
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.