Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
smather
Helper III
Helper III

M Code Percentage Thresholds

Hi

 

I created a custom column in the Query Editor: 

 

if [Phase] = "Equipment" and [Margin] < 20 then "Below Threshold" else null

 

I've also used 0.20/0.19 and 19 to no avail, as it keeps highlighting things as 'below theshold' when they're not, so there's something wrong with my code 😞 I do have the cost/sell and margin £ on this table as well, would it be worth doing the formula to figure out the percentage rather than refering to the Margin % col? If it makes any difference, the margin col pulls through as ie 30.00%

 

Any help would be grand 🙂 

1 ACCEPTED SOLUTION
v-janeyg-msft
Community Support
Community Support

Hi, @smather 

 

You can try: if text.trim([Phase]) = "Equipment" and [Margin] < 20 then "Below Threshold" else null

If it doesn’t solve your problem, please feel free to ask me.

 

Best Regards

Janey Guo

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

10 REPLIES 10
v-janeyg-msft
Community Support
Community Support

Hi, @smather 

 

You can try: if text.trim([Phase]) = "Equipment" and [Margin] < 20 then "Below Threshold" else null

If it doesn’t solve your problem, please feel free to ask me.

 

Best Regards

Janey Guo

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

smather
Helper III
Helper III

@PhilipTreacy 

 

The file is giant and connected to our server, unfort I can't share it. Apologies about the screenshots, lemme try again. I can confirm that the margin is down as % and there's no spaces in any of the phase names (or, there isn't at the source).  

 

I'll give an example of my data (and ideally what it should spit out). Each line is a item, be it labour, kit or licences. And at the visual level, it aggreates them together based off the phase. 

 

Here's some screenshots (I made my own margin box, just in case the one pulling through was playing silly):  

 

SS2.PNGSS1.PNG

 

I just don't understand. All those are for the same project, each line is just another labour day. 

 

Sorry about the new thread, the forum would not let me post a reply to you 😞

Thx @smather 

Well without the actual data to hand I think I've suggested everything I'd check.

If % Margin is 30% as shown in your images then the only thing I can think of is that there are some non-prining characters or spaces in the Phase col, but you said that's not the case.

Can you please humour me and double check with this new column

 = Text.Length([Phase])

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


I think I've figured it! I changed the formula to say <=0.29 rather than <0.30 and it seems to be spitting out what I expected

Hey @PhilipTreacy I was kind of hoping it'd spit out different character lengths because at least thenI'd have a fix

 

SS1.PNG

any other suggestions? I'm game to try anything at this point 🙂 

Carmichael
Advocate III
Advocate III

Can you share a screen shot of the data with the data types visible?

I recreated based on my underrsanding and your formula worked for me.

 

= Table.AddColumn(#"Changed Type", "AND", each if [Phase] = "Equipment" and [Margin] < 0.2 then "Below" else null)

 

Result

Carmichael_0-1616754798966.png

 

Can do! See below: 

 

SS1.PNGSS4.PNGSS3.png

 

There's no spaces in the phase col - the data source doesn't have any, so unless BI is off doing its own thing (stranger things have happened!), that shouldn't be the issue 😕

Hi @smather 

The screenshots are a bit confusing.  Some of it is PQ but doesn't show the custom column, some is a Table viz?

Can you actually share some real data we can test?  Or share the PBIX?

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


PhilipTreacy
Super User
Super User

Hi @smather 

Does the Phase column have text with leading or trailing spaces e.g. " Equipment " ?

Is the Margin column definitely numeric?  It's not numbers stored as text?

If you supply some real sample data it would help to be able to check it.

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


amitchandak
Super User
Super User

@smather , first of check the datatype and some values. Because ideally .2 or 20 one or the value should work

 

Also, check case and space issue with value Equipment in column Phase

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.