How to create a PowerBI New Column by extracting from an existing column? - powerbi-desktop

This is the existing column value: "DisplaySize:0,0.1"
New Column value should be : DisplaySize , if 0,0.1 is present in the existing value, other wise it should be whatever was previously set in the older column.

NewColumn = IF(IFERROR(SEARCH("0,0.1",Column1[Value]),-1)=-1 ,Column1[Value],SUBSTITUTE(MID(Column1[Value], 1,SEARCH("0,0.1",Column1[Value])-2), """", ""))

Related

How to fill out the null values of a column with the first non null value of that column in PySpark

I am trying to fill out the null values of a column of a dataframe with the first value that is not null of that same column.
The dataframe that I want to fill out looks like this, and I want all the rows of the column 'id_book' to have the same number
I have tried the following but it still shows the null values
w = Window.partitionBy('id_book').orderBy('id_book', 'date').rowsBetween(0,sys.maxsize)
filled_column = first(spark_df['id_book'], ignorenulls=True).over(w)
spark_df_filled = union_dias.withColumn('id_book_filled_spark', filled_column)
The window should be
w = Window.orderBy('date').rowsBetween(0, Window.unboundedFollowing)
filled_column = first(spark_df['id_book'], ignorenulls=True).over(w)
spark_df_filled = spark_df.withColumn('id_book_filled_spark', filled_column)
Because you don't want to partition by id_book. There is also no point to order by id_book because only the order of the date matters.
Also I think the better practice is to use Window.unboundedFollowing instead of sys.maxsize.

my dataframe contains '/' in column name , How can i plot certain column values in that column name?

i need to plot the state called 'kerala' in the column 'state/unionterritory' and 'confirmed' to create a lineplot.
so far I have written till
1sns.lineplot(x=my_data['state/unionterritory'],y=my_data['confirmed'])
[https://www.kaggle.com/essentialguy/exercise-final-project]
this is the dataframe.head() , see the column name
I assume you want to get a column state/unionterritory from your DataFrame and filter it so it contains only Kerala state:
my_data_kerala = my_data[my_data['state/unionterritory'] == 'Kerala']['state/unionterritory']

Tabulator update column position programmatically?

Is it possible to update column position with Tabulator?
Or is there a way to do it?
Apparently there is no function to do it.
A moveColumn function will be coming in the 4.2 release next week.
In the mean time you can easily change the order of columns in the table by calling the deleteColumn function and then the addColumn function.
//remove column
table.deleteColumn("age");
//add column elsewhere in the table after the name column
table.addColumn({title:"Age", field:"age"}, "name");
or by changing the column definition array and resubmitting it using the setColumns function
//define new column layout
var columns = [
{title:"Name", field:"name"},
{title:"Age", field:"age"},
{title:"Gender", field:"gender"},
]
//replace all columns
table.setColumns(columns);
Full documentation on these features can be found in the Columns Documentation

Cassandra update query to append data to existing value in a column

Can you please provide the query to append data to an existing value in a column of type text? Something similar to this:
UPDATE cycling.upcoming_calendar SET events = events + ['Tour de France Stage 10'] WHERE year = 2015 AND month = 06;
The above query will update a list. My column datatype is text.
In my case, if the column "events" has a value, "Test" I want to update it to the value, "Test , Test1".
Appending data to a text column is not possible in Cassandra. The only possible options I can think of are
Option 1 : Change the column data type to List
Option 2 : Fetch the data from the column in your application and then append the new value to the existing value, and finally update the DB.

Creating Conditional Column in excel or power bi

I have a problem which can be solved in either excel or power bi. From the image provided i want to create a new column so that the Program/Course will only contain the values Program and values containing Kurs will be in their own column. Is there a way to do that using either excel or Power BI.
I would use the Query Editor to rename the current Program/Course column, then create 2 Conditional Columns to split the data the way you want e.g.
Program/Course = if [Program/Course - Original] <> "Kurs" then [Program/Course - Original] else null
Course = if [Program/Course - Original] = "Kurs" then [Program/Course - Original] else null
Finally I would remove the renamed column.

Resources