In Power BI does anyone have any idea how I can extract a filename from a path in a table column without using SQL? DAX does not seem to have reverse searches. Also please note that some file names do not have paths.
In SQL I could achieve this with the following:
CASE
WHEN #FullPath = 'TRUE' OR CHARINDEX('\', dbo.Usage.App) = 0 THEN
UPPER(dbo.Usage.App)
ELSE
UPPER (RIGHT(dbo.Usage.App, CHARINDEX('\', REVERSE(dbo.Usage.App)) -1))
END
AS AppName
Assuming your fullpath is in Column1, I believe this DAX based solution would work:
Create a new column with...
=RIGHT([Column1],LEN([Column1])-SEARCH("#",SUBSTITUTE([Column1],"\","#",LEN([Column1])-LEN(SUBSTITUTE([Column1],"\","")))))
I found this solution here.
Here's a screenclip that might help too:
Be sure to replace Column1 with the name of your column.
You can try this:
if(SEARCH("\", [App],1,-1)=-1, [App], RIGHT([App],LEN([App])-SEARCH("#",SUBSTITUTE([App],"\","#",LEN([App])-LEN(SUBSTITUTE([App],"\",""))))))
Related
I have a simple problem. Let's assume I have the following
Now I want to add a specific vector or list for example (1,2,2,1) as an additional column and it should look like
When I add "Custom Column", how do I have to enter this list that it creates exactly this column?
It should not be a index column or a calculated column because I want to specify the values depending on another column manually. It seems like it is a very simple task, but I couldn't find any solutions yet! (I feel very stupid xD)
pls help
Thank you!
let Source = #table({"Column1"},{{"A"},{"B"},{"C"},{"D"}}),
Add = {{1,2,2,1}},
part1=Table.ToColumns(Source) & Add,
part2= Table.FromColumns(part1,Table.ColumnNames(Source)&{"Column2"})
in part2
or perhaps, if grabbing column from another table
let Source = #table({"Column1"},{{"A"},{"B"},{"C"},{"D"}}),
part1=Table.ToColumns(Source) & Table.ToColumns(Table.SelectColumns(SomeOtherTable,"Column9")),
part2 = Table.FromColumns(part1,Table.ColumnNames(Source)&{"Column2"})
in part2
Copy your Column1
Open the Enter Data / Create Table UI and paste Column1
Add your specific vector as Column2 and save the new table
Merge the new table into your original table using both Column1
Note that Column1 has to be a key column (unique values). If it's not, create a temporary index column and use that for merging.
I have a table similar to the one attached below:
What I would like to do, using power query, is conditionally filter out (remove) rows where CenterNum = 1101 and DepCode = 257. I figured Table.SelectRows() would work but it doesn't and the query just returns, this table is empty. The #"Expanded AccountLookup" ,in my formula below, is referencing the power query applied step before the one I am trying to create. I'm hoping to get some input on how to remove rows based on these two paramters.
= Table.SelectRows(#"Expanded AccountLookup", each [CostCenterNumber] = "1111001" and [NoteTypeCode] = "257")
Thank you!
You didn’t post a screenshot so it is hard to tell if the column format is text or numerical but try removing the quotes around the numbers
= Table.SelectRows(#"Expanded AccountLookup", each [CostCenterNumber] = 1111001 and [NoteTypeCode] = 257)
If that doesn't work, check the actual column names against what you are using, especially for case (upper/lower) and leading/trailing spaces. The best way to do that is to temporarily rename it, and look at the code for the "from name"
I have the following query in M:
= Table.Combine({
Table.Distinct(Table.SelectColumns(Tab1,{"item"})),
Table.Distinct(Table.SelectColumns(Tab2,{"Column1"}))
})
Is it possible to get it working without prior changing column names?
I want to get something similar to SQL syntax:
select item from Tab1 union all
select Column1 from Tab2
If you need just one column from each table then you may use this code:
= Table.FromList(List.Distinct(Tab1[item])
& List.Distinct(Tab2[Column1]))
If you use M (like in your example or the append query option) the columns names must be the same otherwise it wont work.
But it works in DAX with the command
=UNION(Table1; Table2)
https://learn.microsoft.com/en-us/dax/union-function-dax
It's not possible in Power Query M. Table.Combine make an union with columns that match. If you want to keep all in the same step you can add the change names step instead of tap2 like you did with Table.SelectColumns.
This comparison of matching names is to union in a correct way.
Hope you can manage in the same step if that's what you want.
I thinks this is a very easy to answer question ,but I cant figure it out and im very beginner in DAX.
I have this sample data set:
I want to return a Table in powerbi with only the rows where job is blank. So it would look like this:
How to do this? :)
Because you mentioned DAX, you may use this expression to return a Table with only the rows, where job is blank:
FILTER('Table','Table'[job] = BLANK())
But I guess, it make sense for you only inside the measures, you want to calculate.
Click on the button in the title for job column and uncheck all values, except (Blank):
Okay I know this is really stupid.But how to i write SELECT Column1 FROM tablename
I know i can use Court.objects.all()[0] to get just one row.But how do I get one column only(the whole column values).Am I missing something?
Also in Court.objects.all()[0] isn't it first retrieved and then spliced.So isn't it kinda inefficient.
Court.objects.values_list('column_name', flat=True)
And if you write Court.objects.all()[0] only one row is retireved.
Court.objects.only('column_name')