Default slicer selection (latest date) in Power BI - powerbi

My requirement is when a report will be opened in Power BI services by default, the latest date will be selected in a single select slicer.
Consider in import mode there are 10 dates are coming and assigned to a slicer (single select dropdown). By default it shows the older date as the selected date.
I need to do the opposite. It should be the latest date selected by default and if the user wants to select other dates they can change manually. My landing page by default should show the latest date dynamically.

It's not possible to select the latest date in slicer automatically. However, there is a kind of workaround for this which I have explained below.
Just create an additional column using original date like this:
Date 2 = IF('Table'[Date] = TODAY(), "Today", FORMAT('Table'[Date], "MM-DD-YYYY"))
Then use this newly created column in your slicer and manually select 'Today' in that slicer once and publish the file to the Power BI service. So the end user will always see 'Today' selected in a slicer by default which obviously represents the current date.
Note: if you want latest date to be selected which is not necessarily current date then you can create the column below:
Date 2 = IF('Table'[Date] = MAX('Table'[Date]), "Latest Date", FORMAT('Table'[Date], "MM-DD-YYYY"))

Related

Filtering by Power BI measure not working unless the date column is added to the table

In my Power BI model, I have written a measure to filter the data by the latest date in the model:
LatestDateIndicator = IF(CALCULATE(MAX('Table1'[WeekOf]),REMOVEFILTERS('Table1'))=MAX('wf WeeklyData'[Table1]),1,0)
In the visual filters, I select "greater than 0" to select rows only with the latest date in a date column called WeekOf. It does not work unless I add the column WeekOf to the table.
How can I make it work without adding the column WeekOf to the visual table?

How to display quarterly data in Power BI

I have a Power BI report with a Date (slicer) visual like that.
In a Data Model there is a tabel 'Date' that corresponds to this visual.
At the moment there are only Day, Week, Month and Year dimensions in date selection options. But I would like to see that there is a Quater option too. If I select all date options in 'Date' table then the Power BI doesn't add a Quater option to the previous list but constructs a new visual with different styling (the weekday and month names are in estonian).
The Quarter field in 'Date' table is created like this:
Quarter = Quarter('Date'[Date])
So, my question is why Power BI doesn't add automatically a quarter option to the dropdown menu and are there any solutions for that problem?
Try detectimg column as a date in BI Editor or you may create duplicate column of date to see quarter options.
You can acheive this my selection "Filter" Visualization and drag drop the qtr, month etc in field section.

Power BI Dax Expression Help - Setting default slicer between dates

Power Bi report uses a date slicer (between) - As a default I want it to set the first date in the slicer as Monday (last week) and the last date as Friday (last week). I dont want this to be a relative date but always must be the previous Mon-Fri. I have a column in my data set that tells me which one is the 'Previous Week' as a text field. I dont know how to use this to set a default slicer value. But i also want to make sure the user can change the slicer dates and it changes as per the user request.
Example today is 01/09/2020
I want my default slicer date as : 24/08/2020 - 28/08/2020
I have two measures which gives me by last week dates:
DefaultSD = MINX( FILTER(Data, [WeeksFilter] = "Previous Week Only"),[Date])
DefaultED = MAXX( FILTER(Data, [WeeksFilter] = "Previous Week Only"),[Date])
I assume this is possible using a DAX expression but dont know how to create this expression to populate these default values.
Please note the data is refreshed up until 01/09/2020 so there is currently data for this week but i dont want this to included in the default slicer on report load
You can't set slicer defaults yet but this can be achieved with relative date filtering.
Select date in the last 1 calendar week:

Slicer Only Show Month / Year and Filter On That

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.

Need to limit the date in a slicer by today's date in Power BI

I am building a report in Power BI Desktop, created a slicer - YearMonthSort - which has data selection by Year-Month
Plz, see the screenshot below:
My goal is to limit data in this slicer as -
2015-07 to today's date
(whichever it will be when users will look at the data,
in the same format - "YYYY-MM")
In the "Filters" section I can select my starting year as 2015-07,
but having problem setting today's date.
I tried to create the new Measure, but not sure where to place it,
or, may be there is another way to perform this:
IsToday = FORMAT(TODAY(), "mm/yyyy")
I only just started to learn this,
Thank you for help in advance!
You can do the following:
I am assuming that you are using a calendar table that is joined to your fact table on a date field and that your year sort column is calculated with reference to the 'date' field in your calendar table.
Assuming, this is true you can create a calculated column that will flag whether or not the date field is before or after today. This can be achieved by using the following DAX:
IsToday =
SWITCH (
TRUE (),
'Calendar'[Date]
<= NOW (), 1,
0
)
Then, in your visual add a 'Visual Level Filter' using this new column and set it to 1.