I have my data(file name - Data) which I have imported in power bi with a column named values
values
ext
int
safety_int
outside_training
gap_fill_int
so it is a large data, and it contains more than 2k categories , what I want is, to create a new column in power bi where blanks should be replaced with target_emp, and all other values(ext,int,gap_filling_int etc.) should be replaced with non_target_emp.
Please help me to do that in power bi.
In powerbi transform ->
Add Column:
if Text.Trim([category]) = "" then "target_emp" else "non_target_emp"
You could add a conditional column in the data model (sorry that I dont have an English screenshot for this):
Add column
Select conditional column
Add criteria to selection
#1 DAX
calculatedColumn= SWITCH(TRUE(), Data[Column1]=BLANK(),"target_emp", "non_target_emp")
#2 using PBI's binning
go to report view->click on the table->column name-> New Group
Related
I have a data set and a mapping table as below.
In Power BI, I created a slicer dropdown containing words "Finance Lens" and "Business Lens", This is created using table "Lens" and column "Lens Type"
Based on the selection, I want the grouping to change in the below visuals.
I created a new column as below :
Selected_Lens = If(SELECTEDVALUE(Lens[LensType],"Business Lens")="Business Lens",MappingTable[Business Lens],MappingTable[Finance Lens])
But it is not working... Any idea would help.
I want to create a index column in Power BI but that column must have a string and a number. For example: c1,c2,c3... and not just 1,2,3...
Does anyone know how to solve this problem?
Thank you
Add the index column in Power Query, then choose Add Column From Examples, and enter a few values for the new column. Power Query will figure out the calculated column formula for you. You can then remove the initial index column and rename the new index column.
I have a table with a value ReportDate, which is in the format '03/01/2020'. I want to create a slicer in my Power BI report that displays only the format '03/2020' and the user can then select the value of the month and year to display, and it will display the data for that month (regardless of the day value). How would one go about doing this? I know technically I can add a new column in the database table, but unfortunately I do not have access to changes in the database and as such, would like a Power BI solution.
In the Power Query Editor create a new column with formula
Date.ToText([Date], "MM") & "/" & Date.ToText([Date], "yyyy")
Change [Date] to whatever your date column is called. Date.ToText converts a date time to text, which is then concatenated. You can then filter on that column. For issues like this it is best to have some sort of calendar table.
You can create a new column in using query editor in power bi:
mon_year = left(<column_name>, 3) & Right(<column_name>, 4)
Note: Make sure your are connected to dataset in import mode because in live connection you will not be able to create New Column in Power BI.
I am using SQL server data base. I need to display total no of nights based on checkindate and checkout date. i am new in Power BI.
I tried by quick measure but it is not working.
You can do this in different ways - calculate the duration in the database, add custom column in M or column in DAX.
In SQL Server use select query like this:
select checkindate, checkoutdate, datediff(day, checkindate, checkoutdate) as duration from table
In M (Power Query) - click Edit queries to open Power Query editor and then Add Column -> Custom column:
Duration.Days(Duration.From([checkoutdate]-[checkindate]))
In DAX - right click your table and select New column:
Duration_DAX = DATEDIFF('Table'[checkoutdate]; 'Table'[checkindate]; DAY)
Note, that depending on your settings, you may have to use comma (,) instead of semicolon (;) in the DAX expression above.
I need to take the DistinctCount(InvNumber) of a InvNumber column by creating a new measures that is #NoofInvoice,
I need to show that column In MY report, but Column #NoofInvoice I want to take on Condition that If(OrderType='SALES' and OrderType is a column which contain two values SALES and RETURN or then only I need distinctcount(InvNumber)) in Power bi
How about if you create a new measure called "No. of Invoices" like this:
No. of Invoices = CALCULATE(DISTINCTCOUNT(InvNumber), FILTER(Table_Name, 'Table_Name'[OrderType] = "Sales"))
Let me know how you go with it! :)