Power BI - filter data to current week (week number) - powerbi

I have a power bi report with a line chart that has a field called 'EventDate'
I need to add a filter on to this report to say 'only get me the days where the EventDate matches this week number'
I don't want to display the last 7 days as a relative filter.
I need to do it by this week.
Can anyone help

You can use the week in the relative date filtering and it returns the dates associated with the current week number rather than the last 7 days.

Related

How to sort week end date in the date table in Power BI?

I am new to Power BI, having below date table
Created Week end date using below dax measure
Week End Date = 'Date'[Date] - WEEKDAY('Date'[Date],2) + 7
Can anyone advise the following?
How to sort the week end date? I created bar graph week end date vs Total hrs(which comes from other table) and it's working. However, axis week end data is not in proper order
How to format week end date into "MM/dd/YYYY" (Currently in "dd/MM/yyyy")
Sorry if this question is too basic. I tried various posts but no luck.
You cut your bar chart screenshot exactly on the ellipsis menu (...) in the upper right corner. This is usually the place to go and change the sort order of your x-axis. (Maybe your data doesn't allow this, but then you would need to post some sample data - no screenshot - as already requested above.)
To change the format to "MM/dd/YYYY" use
End of Week US = FORMAT('Table'[End Of Week], "MM/dd/yyyy")

How to automatically update Slicer in Power Bi to Today's Date

I am having a power Bi Report which has a slicer the date column is coming from SQL.
I have Current months Dates till 28-june-2022 and Last years dates in Sql till 30 June 2021
I want only Values to be displayed for todays date in the 2021 Slicer and not all the dates till 30
Screenshot of the Slicer is below
I don't want the Yellow Dates I want the dates to get added automatically when i refresh the other day.
I can do this manually with a filter which is not feasible
If I understand your question correctly, you only want a list of dates within the date range of today and last-year's today. That is the same as the last 12 months of dates. You can do this in the filter pane:
Be sure to un-check the 'Include Today' option.
Another option to select a list of dates between any set of dates is with a measure. Use the following measure to define whatever range of dates you would like. I have done the last full year of dates as an example:
DAX_Dates =
CALCULATE(COUNT('Date'[Date]) --Counts number of records
,KEEPFILTERS( --Allows the filter context of the visuals to dynamically evaluate the calculation
DATESBETWEEN('Date'[Date] --Defines a range of dates to apply the calculation
,DATE(YEAR(TODAY())-1,MONTH(TODAY()),DAY(TODAY())) --Start Date
,TODAY() --End Date
)
)
)
Next, you can filter the visual with the measure.

Date filtering of DAX measure in pivot chart

I have created 3 DAX measures in Power Pivot to calculate backlog value and I have an issue with filtering in pivot chart. When I filter out a specific time period, the backlog calculates only based on filtered dates. Instead of filtering, I would like to only "zoom in" to some specific time-range.
Measures
Opened:=CALCULATE(COUNTA([CreatedOn]))
Closed:=CALCULATE(COUNTA(Ticket[ClosedOn]),USERELATIONSHIP(Ticket[ClosedOn],'Calendar'[Date]))
Backlog:=CALCULATE([Opened]-[Closed],FILTER(ALLSELECTED('Calendar'),'Calendar'[Date]<=MAX('Calendar'[Date])))
Based on example data below, without filtering any dates the backlog value is following:
Date;Backlog
1/1/2021;1
2/1/2021;3
3/1/2021;1
4/1/2021;3
When I filter dates excluding 1st of January, I get following values:
Date;Backlog
2/1/2021;2
3/1/2021;1
4/1/2021;3
I want to get same values as without filtering the date. I just want to to "zoom in" on some specific date range. In my case i have 1 year of input data and want to see the backlog evolution of last 8 weeks. So when I filter last 8 weeks, my first week shows only value calculated for that week, but instead it should take into account all the values from previous periods + the result of first week
Example data
TicketNumber;Type;CreatedOn;ClosedOn;Status
ticket1;Service Request;1/1/2021;1/3/2021;Closed
ticket2;Incident Record;1/2/2021;1/3/2021;Closed
ticket3;Incident Record;1/2/2021;1/5/2021;Closed
ticket4;Service Request;1/4/2021;;Open
ticket5;Service Request;1/4/2021;;Waiting for
Fixed thanks to my colleague! :)
I had to change ALLSELECTED to ALL
Backlog:=CALCULATE([Opened]-[Closed],FILTER(ALL('Calendar'),'Calendar'[Date]<=MAX('Calendar'[Date])))

How to filter YTD to last complete month in Power BI

I am creating a report with buttons that use a slicer to show the last 3 calendar months, the default view, and YTD. The first two are all set and will continue to work fine, however i am having trouble with the YTD filter because i need it to exclude the current month (some of the key metrics for this slicer are only accurate monthly, even thought the data is updated Daily). Any idea how to accomplish this without me having to manually change it every month? An example of it working today would show me 2020 through August, since September is not complete. September would be included in the filter starting October first. I am thankful for your help/insights!
I typically build a calculated column on my date table called something like "Date in Range", that looks something like the below. You could also apply this to a date in a normal table if you are not using a date dimension.
Date in Range = IF ('MyTable'[Date] <
DATEADD(TODAY(), -1 * DAY(TODAY()), day),
1,
0)
This compares the date in the table row with TODAY(), e.g. 14 Sep 2020, minus the day of the month of today (14), effectively getting you back to the start of the current month. This will then return 1 for dates before the end of last month or 0. Filter on 1 or 0 to get your result (or use something more meaningful in place of the 1 or 0).

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: