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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

Differentiate between Text & Number and if Text return as Zero

Hello Everyone,

I have a column having results which comprise numbers and text. I am looking to create a new measure which shall work on the logic that if there is a number value in the existing column then just keep it as in the new measure and if there is a text "BDL" in the existing column then mark zero "0" in the new measure.

 

 

Existing Column New MeasureLogic
Result Result 
60 60If number, keep it as is
70 70If number, keep it as is
67 67If number, keep it as is
80 80If number, keep it as is
BDL 0If BDL, then mark it as Zero
60 60If number, keep it as is
77 77If number, keep it as is
BDL 0If BDL, then mark it as Zero
86 86If number, keep it as is
120 120If number, keep it as is
BDL 0If BDL, then mark it as Zero
50 50If number, keep it as is
45 45If number, keep it as is

 

Any help is highly appreciable.

 

Thanks 

Samrat

1 ACCEPTED SOLUTION
OliT
Resolver I
Resolver I

Hi @Anonymous 

you can  try this measure

when the current row contains "BDL", CONTAINSSTRING() will return true, then test will return 0, else return current row.

test = IF(CONTAINSSTRING( MIN('Table'[Existing Column]),"BDL"),0,MIN('Table'[Existing Column]))

OliT_0-1660209249075.png

 

Regards,

OliT

View solution in original post

3 REPLIES 3
v-henryk-mstf
Community Support
Community Support

Hi @Anonymous ,

 

Whether the advice given by @OliT  has solved your confusion, if the problem has been solved you can mark the reply for the standard answer to help the other members find it more quickly. If not, please point it out.


Looking forward to your feedback.


Best Regards,
Henry

OliT
Resolver I
Resolver I

Hi @Anonymous 

you can  try this measure

when the current row contains "BDL", CONTAINSSTRING() will return true, then test will return 0, else return current row.

test = IF(CONTAINSSTRING( MIN('Table'[Existing Column]),"BDL"),0,MIN('Table'[Existing Column]))

OliT_0-1660209249075.png

 

Regards,

OliT

MahyarTF
Memorable Member
Memorable Member

Hi,

In Power Query add the 'Custom Column' and write the below M query :

if Value.Type([Result]) = type number then [Result] else 0

MahyarTF_0-1660023377400.png

 

Mahyartf

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.