I load a monthly data from a text file every month. In the table, there is a column that has string values with some extra strings with a fixed length. So the column looks like the following:
**OriginalColumn**
String1_XXXXX
String2_XXXXX
...
StringN_XXXXX
I would like to get rid of this extra fixed length string from the original column and I can do that by creating a new column something like:
NewColumn = LEFT(OriginalColumn,LEN(OriginalColumn)-6)
I am looking for a way to create a measure instead of a column. This is because as this is a monthly process that I would like to reduce the manual operation every month to create a new column. If using a measure, only data can be replaced.
Is there any way to do that? I have not found a measure that is working. When I create a measure I always need to wrap a column that has string values with some function such as MAX(SomeColumn). I always thought there should be a better way.
Would somebody kindly advise?
Thanks & Regards,
Kyoto
No need for a calculated column or a new measure, this can be done in a power query editor to remove the fixed length string from the original column before loading it into your model.
Related
I need some help creating a measure to change the name of "FROM_USER" in the slicer here.
I think I need to use the function SELECTEDVALUE, but I have not managed to get it working.
So, the column has only two values, CRAWLER and FROM_USER.
Any suggestions would be helpful!
See picture
Measures can't be used as slicer values. If you want the column values to be changed and yet to be used in a slicer, you need to create a calculate column to change that.
Column = IF('Table'[Column1]="FROM_USER","desiredValue","CRAWLER")
If you are really keen on using a measure to slice, you need to build a disconnected table and follow the method described here. But the performance will take a hit depending on how complex your data model and calculations are.
I want to calculate % of two columns which are already in %.
I want to calculate formula like
Target achieved= ACTUAL/TARGET
But here is ACTUAL is already a measure/calculated metrics so I'm not able to divide these two columns.
Any help would be appreciated..
Make sure both target and actual are actually numbers and not strings. You can do it in transform data (aka Power Query) part, before data is loaded into the report.
After that you should be able to create the measure you want, e.g. something like that:
UPDATE : What happens if Actual is not a column, but a measure?
If Actual measure is based on the columns in the same table as target you shouldn't have a problem. You cannot combine measure and column in the same formula. Measure is an aggregated field and needs to be grouped by another field (if you are familiar with SQL,think of SUM and GROUP BY). Coming back to your problem, you need to create measure out of "Target" column as well (notice I have in the formula SUM('Table'[Plan]) which makes it a measure). Than you can use both of them in the formula, but of course you need to "group" them by something(e.g. date) otherwise it will just show you a total.
I want to display some raw records (i.e. not aggregated) in a chart table.
I don't see a way to control number formats in this chart.
I have tried the following:
When looking at the column definition in the dataset, the format field only applies in case of datetime.
Also if I create metrics, I can only use them in aggreage table.
Creating a calulated column doesn't help either.
As a result of this, here is the kind of table I get:
How should I proceed to solve this?
Use a calculated column and change it to a datatype with precision.
CAST(myRecord as double(10,2))
Hello M language masters!
I have a question about working with grouped rows when the Power Query creates a table with data. But maybe it is better to start from the beginning.
Important information! I will be asking for example only about adding an index. I know that there are different possibilities to reach such a result. But for this question, I need an answer about the possibility to work on tables. I want to use this answer in different actions (e.g table sorting, adding columns in group table).
In my sample data source, I have a list of fake transactions. I want to add an index for each Salesman, to count operations for each of them.
Sample Data
So I just added this file as a data source in Power BI. In Power query, I have grouped rows according to name. This step created form me column contained a table for each Salesman, which stores all his or her operations.
Grouping result
And now, I want to add an index column in each table. I know, that this is possible by adding a new column to the main table, which will be store a new table with added index:
Custom column function
And in each table, I have Indexed. That is good. But I have an extra column now (one with the table without index, and one with a table with index).
Result - a little bit messy
So I want to ask if there is any possibility to add such an index directly to the table in column Operations, without creating the additional column. My approach seems to be a bit messy and I want to find something cleaner. Does anyone know a smart solution for that?
Thank you in advance.
Artur
Sure, you may do it inside Table.Group function:
= Table.Group(Source, {"Salesman"}, {"Operations", each Table.AddIndexColumn(_, "i", 1, 1)})
P.S. To add existing index column to nested table use this code:
= Table.ReplaceValue(PreviousStep,each [index],0,(a,b,c)=>Table.AddColumn(a,"index", each b),{"Operations"})
tried to figure this one myself to no luck and couldn't find similar problem through Google.
I have a number of tables within PowerBI dashboard, one table is a stock table that has values for random dates throughout the month, what i am trying to figure out is, how can i use dates from DayDim table(that has all dates for a month) in a table view and have a measure that would fill in missing dates with the most recent value from the stock table.
Please see a simplified representation as per image attached.
Of course in that stock table i have numerous products and customers etc. for each of those dates, so i would need to have the ability to still calculate values within those contexts, rather than just a total value number.
any help greatly appreciated, thank you in advance.
If you realy need this you can go with an extra column on your Day Dim table (or create a new table).
Value = LOOKUPVALUE(stock[Value];stock[Stock Date];
CALCULATE(MAX('Day Dim Table'[Date]);
FILTER('Day Dim Table';'Day Dim Table'[Date] <=EARLIER('Day Dim Table'[Date]) && RELATED(stock[Value]) <> BLANK())))
Please ensure you create a relation on date between the 2 tables.
I do wonder why you need it because I do not see the point of creating extra data but then again, I do not know your requirements..