I am creating a Month table to be included in my Power Bi Dashboard as a Filter.
I create a separate table joined to main table, but unable to select the option from the menu to Sort By Column- Greyed out.
What am I missing. I just want a filter of Months (Jan, Feb, Mar, etc) in numeric order. Can someone direct me to a good how to?
If a sort has already been specified, it will be greyed out.
Click on the Data icon in the upper left.
Click on the column that may have a sort on it.
Click Clear Sort.
Click on another column, then click back to the column you want to sort.
Sort By Column will no longer be greyed out.
When you create Report using Power bi data set (not connect directly to database) you cant use column sort it will appear disabled
Appending numbers to the beginning of your linked Month table might help you issue.
If your data looks something like this..
Revenue by month ID
Month table
Then make sure your month table is formtted like so in PBI
You can then filter like so
Alternatively, you could format the sorting month column to text and filter like so:
There's a cleaner way to do this. It's demonstrated starting at about 10:50 in this video.
https://youtu.be/d2bZpNZ6uIA?t=10m50s
You'll need to have a column of number values that correspond to the text values and then tell Power BI to sort by the number column. You can add such a column with "Enter Data" if it doesn't exist.
The preferred way to do this is to use a sort by column that looks like this:
Month | MonthSort
Jan | 1
Feb | 2
Mar | 3
Apr | 4
May | 5
Jun | 6
Jul | 7
Aug | 8
Sep | 9
Oct | 10
Nov | 11
Dec | 12
Then on the modeling tab, select the Month column. Then click the Sort By Column button in the ribbon and select MonthSort.
https://learn.microsoft.com/en-us/power-bi/desktop-sort-by-column#sort-using-the-sort-by-column-button
This is an old post, however, I was not able to solve based on above answers. So updating based on what helped me.
In Power query editor, create a new column in the same table as month number for corresponding month. Apply the changes and return to report screen.
In report screen, select the field "Month", go to modelling and click sort by "Month Number". Note:- this makes Month to be sorted based on Month number rather than alphabetical.
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 would need your support if possible..
Currently within my dataset there is a table "SUM" like below, where columns "Jan" and "Feb" contains both decimal and whole numbers data types.
Is it possible to convert some of the whole number to currency and some other to decimal with 2 decimal places ?
SUM TABLE
title
Jan
Feb
New users
80
90
users
200
150
BV
74562.62
82617.93
Charge
0.063629
0.061740
______________________________________
desired output
title
Jan
Feb
New users
80
90
users
200
150
BV
$745,626
$826,179
Charge
0.06
0.06
______________________________________
I think that in Power BI a column has only one data type.
Is there any way to achieve the desired output?
Thanks in advance
It would be best to structure your data, into a format that it can be used for example, change data types and creating measures.
In this example, using the query editor, you need to first Unpivot your Jan/Feb columns from columns to rows
With unpivot it becomes this:
You then need to Pivot your data on the Title, select the column 'Title' Pivot on the Values column created in the previous step
This now allows you to correct your formatting, create measures, and also map by month better, without the need for complicated DAX formatting when creating measures
To display several data type within a column, you need add new measure for each month you prepare to display and accept the answer if helping :)
Here is the dax formula for Jan, you may need calcuate for Feb if necessary:
Measure = IF(SELECTEDVALUE(Sheet1[title])="BV",FORMAT(SUM(Sheet1[Jan]),"Currency"),
IF(SELECTEDVALUE(Sheet1[title])="Charge",FIXED(SUM(Sheet1[Jan]),2),
FORMAT(SUM(Sheet1[Jan]),"General Number")))
By display the measure on the table, you will have the result:
To display different data types in a table, you can create a measure with the following DAX for the Feb column, you can do the same for other columns too.
Measure =
VAR VAL = SUMMARIZE('Table','Table'[Feb])
RETURN SWITCH( SELECTEDVALUE('Table'[Title]),
"Users", FORMAT(VAL, "0"),
"BV", FORMAT(VAL, "$0"),
"Charge", FORMAT(VAL, "0.00"),
"New Users", FORMAT(VAL , "0")
)
Hopefully a quick explanation of what I am hoping to accomplish followed by the approach we've been working on for over a year.
Desired Result
I have a table of SCD values with two columns, SCD_Valid_From and SCD_Valid_To. Is there a way to join a date table in my model (or simply use a slicer without a join) in order to be able to choose a specific date that is in between the two SCD columns and have that row of data returned?
Original Table
ID | SCD_Valid_From | SCR_Valid_To | Cost
1 2020-08-01 2020-08-03 5.00
Slicer date chosen is 2020-08-02. I would like this ID=1 record to be returned.
What We've Attempted So Far
We had a consultant come in and help us get Power BI launched last year. His solution was to create an expansion table that would contain a row for every ID/Date combination.
Expanded Original Table
ID | SCD_Valid_Date | Cost
1 2020-08-01 5.00
1 2020-08-02 5.00
1 2020-08-03 5.00
This was happening originally on the Power BI side, and we would use incremental refresh to control how much of this table was getting pushed each day. Long story short, this was extremely inefficient and made the refresh too slow to be effective - for 5 years' worth of data, we would need over 2000 rows per ID just to be able to select a dimensional record.
Is there a way to use a slicer where Power BI can select the records where that selected date falls between dates in two columns of a table?
Let me explain a workaround and I hope this will help you to solve your issue. Let me guess you have below 2 tables-
"Dates" table with column "Date" from where you are generating the date slicer.
"your_main_table" with with column "scd_valid_from" and "scd_valid_to".
Step-1: If you do not have relation between table "Dates" and "your_main_table", this is fine as other wise you have to create a new table like "Dates2". For this work around, you can not have relation between those tables.
In case you have already relation established between those tables, create a new custom table with this below code-
Dates2 =
SELECTCOLUMNS(
Dates,
"Date", Dates[Date]
)
From here, I will consider "Dates2" as source of your Date slicer. But if you have "Date" table with no relation with table "your_main_table", just consider "Dates" in place of "Dates2" in below measures creation. Now, Create these following 4 measures in your table "your_main_table"
1.
date_from_current_row = max(join_using_date_range[SCD_Valid_From])
2.
date_to_current_row = max(join_using_date_range[SCD_Valid_to])
3.
date_selected_in_slicer = SELECTEDVALUE(Dates2[Date])
4.
show_hide_row =
if(
[date_selected_in_slicer] >= [date_from_current_row]
&& [date_selected_in_slicer] <= [date_to_current_row]
,
1,
0
)
Now you have all instruments ready for play. Create your visual using columns from the table "your_main_table"
Final Step: Now just add a visual level filter with the measure "show_hide_row" and set value will show only when "show_hide_row = 1".
The final output will be something like below image-
I'm using Power BI, pulling data from a SQL server, but for a column containing date, it keeps splitting into 4 other columns when I try and show it in a table:
Year | Quarter | Month | Day
Has anyone had this issue before?
Note: Under modeling, when selecting that field I did try placing Data Type as Date. No change.
This is because Power BI made a date hierarchy from this field. If you do not want this, right click it in the designer and uncheck Date hierarchy from the menu:
I'm trying to overlay three different columns in one chart on Power BI Desktop.
To try to show a comparison of the number of orders per month by different years I have one column for Order Number, and three other columns for Sale Date; Sale Date 2016, Sale Date 2017 and Sale Date 2018. For each order number the three Sale Date columns have a number from 1-12 (representing the month in that year that the order occurred) or a null value (if the order occurred in another year). Something like this:
I'm trying to overlay the three Sale Date columns as individual lines on a line chart with Order Number (Count Distinct) as one axis and Sale Date 1-12 as the other axis. I would think that this would be comparatively simple but Power BI Desktop doesn't seem to have an option to set this up. I'd be open to other types of chart too, as long as the different years can be easily compared.
The reason you're having trouble is that your data is not shaped in a way that is conducive to the way Power BI works.
I'd recommend unpivoting your Sale 201x columns in the Query Editor before trying to do anything. When you do this, your data will look like this instead.
Order # | Year | Month
--------|-----------|------
101 | Sale 2016 | 6
102 | Sale 2017 | 8
103 | Sale 2018 | 12
104 | |
When it's in this format you can use it in a visual much more easily using Order # on your axis and Month for values while using Year as your legend.