i need help on cleaning this data. Currently I've no idea to clean this kind of data. I want to clean based on month and total per supplier. Thanks
Select the first 2 columns [No] and [Supplier]
On the tab Transform drop down Unpivot Columns and click on Unpipot Other Columns
This converts your wide pivot table into a long, stacked format that is ideal for further processing.
Another way you can achieve this is
Select all the date columns.
Click on the transform tab, under any column section, click on unpivot only selected columns
Kindly rename the Attribute column to date
If you need to split the date column into month and year
4. on the transform tab, under the text column section, click on Split Column, select "by delimiter" on the dialog box, select split at the left-most delimiter and click ok.
You will have your month and year columns as shown below
if your value column holds figure for amount/money you can transform the data type and replace the null values with zero using the replace values function when you right-click on the values column.
I hope this helps
Related
I pulled data into Power BI from a SQL query which returns only the order year in one of the columns. In Power BI I formatted the column as "Data type Date" and "Date time format 2001(yyyy)", but when I pull that column into a table in Power BI, it's clearly calculating 2020 and 2021 as the number of days from 1/1/1900 (like excel) because it shows the year as 1905 for both when inserting this column into a visual, instead of years 2020 and 2021.
How can I format this column as the year 2020 and 2021?
Thank you,
You can convert it in the data source, or you can add a custom column in Power Query with M, or a calculated column in the model with DAX. If your data is not too much, it doesn't really matter where you will do that, but the general recommendation is to do that as close to the data source as you can (i.e. if you can, add it to your query, or if you can't add a calculated column).
The data source option needs a column in your query, which can be added with expression like this (this one uses DATEFROMPARTS T-SQL command, if you are using another database, you will have to change it):
DATEFROMPARTS(ExistingYearOnlyColumn, 1, 1)
Or click Transform data to open Power Query Editor and click Add Column -> Custom Column:
and use #date to create the date:
The last option is to create a calculated column in DAX, by right-clicking on your table and selecting New column:
And use DATE DAX function in an expression like this:
DateColumn = DATE([ExistingYearOnlyColumn], 1, 1)
I have a line chart in powerBI with the last 6 months as a legend (Sep,2020 - Feb,2021). The issue is that I want to have the months sorted by year (Sep-2020, Oct-2020....Jan-2021, Feb2021) but I can't insert both year and month in the legend and it accepts only one of them:
I have tried to make a new column in the edit query section that extracts the value (year-month) from the "Create_date" date column. But when I insert this column in the legend it takes all the values from all of my data, and not the last 6 months. The date filter I have is for the original "create_date" column.
One way is to add a new column via the Power Query Editor that computes the legend for you. There maybe another funky way but this is how I would approach it.
The column has the following function
= Table.AddColumn(#"Expanded Content", "Date For Legend",
each Number.ToText(Date.Year([Timestamp])) &
"-" &
Text.PadStart(Number.ToText(Date.Month([Timestamp])), 2, "0") &
" " &
Date.MonthName([Timestamp])
)
This basically take my column called [Tmestamp] and formats it to a string field for my legend use. Note as 2020-09 comes before 2021-01 everything is in order.
and then change the legend value on the line chart to Date For Legend
Currently, I have a report that displays a series of data that I can filter on the basis of a "date slicer (type 'between')". This slicer works with as specifi column "i_date" because a date table (m_date[date]) is used for the slicer and the "i_date" (from another table "interv") is linked together (1:n relathions).
In this other table there is another date type column with the last modification date of the row (interv[modified]).
Now, when a period is selected with the date slicer, I'd like to show the data where interv[i_date] OR interv[modified] are inside the selected period.
How can I do that ?
Using a new column with the newest date between interv[i_date] OR interv[modified] is not a solution, because in this case if a row is modified after the period, it will not be shown. (because interv[i_date] < interv[modified])
solved with a second slicer simply
I have a table visual with a date column and I have a requirement to highlight the top 2 rows. The data on the table visual is sorted desc by the date column.
I need help to conditional format the background color for the top 2 rows.
I tried searching for a way to do this but no luck.
You can calculate the rank of the rows and use conditional formatting to highlight the top 2 rows. But first, we need to define what "top 2 rows" means. You said it is sorted by date descending, so I will assume that "top 2 rows" means the rows with the 2 biggest dates. I will use a measure, which will respond to filters applied on the data. Then we will highlight the rows with rank 1 and 2 (assuming dates are unique in table's rows).
Make new measure like this:
Measure = RANKX(ALLSELECTED('Table'); CALCULATE(SELECTEDVALUE('Table'[Date])))
Where Table is your table name, and Date is the name of the date column. This will give you a number (1, 2, 3...) where 1 is the row with the biggest date, 2 is the second biggest date, and so on.
Then for every field shown in your table, add the following background color condition (right click each item in the list of fields and select Conditional formatting -> Background color):
Set Format by to be Rules, select your measure in Based on field and ad condition > 0 and <= 2 to set the desired background color. Repeat this for all fields shown.
I am infant to power bi , And Below is the data which resembles to my
data set in Power BI
And below is result for the above data table
But my client wan'ts the dot lines in it and he is expecting the
report result to be as below
Can any one please help me how can I make it
First unpivot the Quarter columns:
-Click 'Edit Queries' at the top
-Select "Transform' tab
-Select the 4 quarter columns (Select 1st column, shift click last column to selct them
-Select 'Unpivot Columns'
-Back to home tab, close and apply
Now add a line chart visual. Place the new column (Which depicts the quarter) in the 'Axis' field. Place the values for the companies in the Values field.