Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hello Friends,
I have an Excel Sheet with details related to "Products" of a footware brand, which contains a Column named 'Size' with different data types like 'Text', 'Integer' and also 'Null values'.
I tried to import this data and converting the "Size" column values to 'Text', this has saved me from the Errors that I was getting earlier on converting Text to Interger, but the problem is now I can't do mathematical opertaions with this numerical data, as now all the values are of Data Type 'Text',
can someone please provide me the solution of this problem,
I would really appreciate the help!
Thanks a lot in Advance! 🙂
Hi,
What mathematical calculations do you want to do on that column?
Hey Ashish,
Actually in this problem, we have 'Size' column but this happen with any other data column, let say with sales or profit, those are crucial to calculate Monthwise sale or sum of total sales etc. it can be used to draw many insights, that's why I am curious to know the solution of this type to "Multiple Data Type" problems.
We can solve this 'Size' column by Replacing the Text with their respective size numbers,
For eg: X with 40 or 38 but I wanted the solution of this type of problem as General.
The example yo have taken is incorrect. To calculate profit/loss, you will only have numbers in a column. If you can tell me what you wnat to do with that size column (which has entries of mixed data type), then i can possibly help.
@abhinav_003 , to address your problem,
the answer should be similar to what @v-yangliu-msft offers:
To create a calculated column like the following:
Column =
IF ( ISERROR ( VALUE([Column1]) ), SWITCH([Column1],"X",40,[any other things you needed]),
FORMAT(
VALUE([Column1]),"General Number"))
You can check to see if this works. I didn't test that actually.
Hi there!,
I tried using that but the below error message is reflecting:
Please let me know if I did it wrong.
Thanks & Regards,
Abhinav
Edit:
The following is even more concise. I will leave my original answer here for your reference.
Calculated_Column =
SWITCH(FORMAT('Table'[Size],"Text"),"L",1,"M",2,"S",3,"XL",4,VALUE([Size]))
I have actually tried that on PowerBI, this should be working.
Calculated_Column =
IFERROR(VALUE([Size]),SWITCH(FORMAT('Table'[Size],"Text"),"L",1,"M",2,"S",3,"XL",4,VALUE([Size])))
Hi @abhinav_003 ,
Here are the steps you can follow:
1. Create calculated column.
Column =
VAR x = ( [Column1]- 2 )
RETURN
IF ( ISERROR ( x ), [Column1],
FORMAT(
VALUE([Column1]) + 10,"General Number"))
2. Result:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
hi @abhinav_003
you may split the column into two, like:
https://community.powerbi.com/t5/Desktop/Extract-number-and-text-from-string/td-p/1190132
Hi @FreemanZ ,
First of all, thank you for your reply,
Actually I have data like this:
Number in one row and Text in another, spliting them in different columns won't work in this case, I might not be clear in explaining it that time.
So, what should we do in this situation.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
104 | |
101 | |
79 | |
72 | |
64 |
User | Count |
---|---|
142 | |
108 | |
101 | |
81 | |
74 |