Power BI: Inserting both year and month in line chart legend - powerbi

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

Related

Clean Data in Power BI

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

Conditional Format top 2 rows of a table visual power BI

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.

data points and straight lines in Line Chart

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.

Date range filter in clustered column chart

In my Power BI report I have a date slicer and a clustered column chart. In the chart I want to display how much events occurred per hour. For that I have a data table like this:
Date Hour Count
01.01.2019 07:00:00 4
01.01.2019 09:00:00 9
03.01.2019 07:00:00 1
07.01.2019 10:00:00 14
and so on ...
The charts x-axis displays the hour, y-axis the count.
Now I want to be able to filter the chart by date when I change the date range in the slicer. For example when I set the slicer to the range from 04.01.2019 to 10.01.2019, the chart should display the hour histogram only of these 7 days.
Hope you have an idea what I want to do.
Thanks in advance!
EDIT
I've found out why it is not working. The report contains multiple charts, each bound to an own data table. Each table has a date column. The slicer uses one of these date columns, but not the one of the data used by the clustered column chart. Now the date column of the clustered column chart can contain one date multiple times. But the date column which is used by the slicer contains each date only once.
The data table used by the slicer looks like this:
Date some other columns
01.01.2019 ...
02.01.2019 ...
04.01.2019 ...
...
Each date is contained once at the most in contrast to the date column of the first table, where each date can appear more than once. Because of this the slicer works for the one chart but not for the other.
Ok, found the solution and it is very easy. All you have to do is to create a relationship between the date column of table two and the date colum of table one. The slicer uses the date column of table two. If you change the date range now this affects the clustered column chart too.

Display year,quarter,month and day Charts based on the selected Date

There are four line charts for Year,Quarter,Month,Day in my power bi report. the requirement is to pick a date from the date picker and based on the selected date I need to display graphs accordingly(selected date and 3 values back). E.g. if user select 1.1.2018 from date picker, I need to display graphs with year,quarter,month,day belong to 1.1.2018 and 3 more values(years,quarters,months,days) back.
I add visual level filters for each line chart and filter top 4 values.but it's work for year chart only. any ideas?
Dashboard_1
Dashboard_2
Data
Hey Dasaru try to create separate columns for year, quarter, month & date and use that as Axis in each chart
FYYear = Sheet1[Period].[Year]
FYQuarter = Sheet1[Period].[Year]&" "&Sheet1[Period].[Quarter]
Apply the same solution for Month and Date.