I have 2 date column in my table ie entrydate and exitdate and also containerno column and 1 seperate date table in power bi.
Now the case is -
I have 1 date slicer in report.
Need to count no of days in monthly basis.
Eg if my container enter in 20-nov-2020 and exitdate is 5-Dec-2020
So when we select 26-nov-2020 in my date slicer then
Required output is 6 days.
Means then my selected date will become my exitdate.
And when we select 1-dec-2020 to 10-dec-2020 then
Output is 5 days
So my entry and exit date can be dynamic based on selected date by comparing with entrydate and exitdate
Related
I have 2 date slicers and a measurement which is [Profit], I would like to return the difference in Profit given the date selections. Please see below for detail.
Date Slicer 1: 3/7/2021-3/13/2021
Date Slicer 2: 3/14/2021-3/20/2021
Profit given Date Slicer 1: 10
Profit given Date Slicer 2: 15
Value I am trying to get = 5 (15-10)
If the two slicers come from the same Date column, both periods do not intersect each other and you get a filter without dates.
Possibly there are better solutions but one of them would be to use a Harvester Filter (Creating an additional table containing a copy of the date column unrelated to the model, aka Disconnected Tables)
Before moving on to the next part you can verify that the filter contains the same dates but since it is a disconnected table, it does not filter the model, yet
For the [Profit given Date Slicer 1] you can use the original measure
For the [Profit given Date Slicer 2] you must change the filter to:
DATESBETWEEN(
'Dates'[Date],
MIN(HarvestingDates[Date]),
MAX(HarvestingDates[Date])
)
I have a report where I have sales data for end of every month. When I see the data in drop down ,I can see the end of month date , but when I have used slicer it shows the entire date range and not only the last day of the month. Is there any way in slicer through which I can just limit the date, so that only last day of month will be shown in slicer ?
If you have a dates table with a date field (named Date, in this case), you could add a column with this code: Table.AddColumn(PreviousStep, "EndOfMonth", each Date.EndOfMonth([Date]), type date)
I have a table containing a date field (from 1 March 2020 to now) that I need to filter to a specific date and the previous 6 days to give complete week's data. So if I chose 30 March I'd get a table of 24 March to 30 March. If I then chose 31 March the table would show 25 March to 31 March.
I can use a date slicer to choose a range of dates but I want to be able to pick a single date, with Power BI automatically selecting the earlier date.
Any pointers much appreciated.
Mark.
You can create two measure - one for Slicer selected date and Another one with 7 day minus from the selected date as below-
Considering your date table name is- Dates
selected_date = SELECTEDVALUE(Dates[Date])
seven_day_starts_from = DATEADD(Dates[Date],-7,DAY)
Now create your calculated measure first like-
total_sales = SUM(Sales[sale])
Here comes how you will always calculate last 7 days sales considering the selected date in the slicer-
7_day_sales =
(
CALCULATE(
[total_sales],
DATESBETWEEN(
'Dates'[Date],
[seven_day_starts_from],
[selected_date]
)
) + 0
)
Remember, this is just a sample flow showing how it should work. You should try to follow the steps with your data and table structure. Dates table is a calendar table and Sales table is connected to the Dates table using the Date column.
I have a dahsboard where I select year and charts are filtered based on the year selection. I have a line chart which is not linked to the slicer (interactions turned off) but I would like to display data related to 6 years prior to the date selected. Hence I thoght of creating a measure value that subtracts the selected year with the remaining years and apply that as a filter to my chart so I display values only where difference is 1,2,3,4,5 or 6.
You can create a measure to calculate the difference and use SELECTEDVALUE to get the year selected in the slicer. If we say, that you have a table named Table (Data) with column Year containing your data, and table named Table (Years) with column Year, which is your calendar table containing the list of years shown in the slicer, then the measure can be calculated like this:
Measure_Diff = SELECTEDVALUE('Table (Years)'[Year]) - MAX('Table (Data)'[Year])
Then you will get the number of years difference between the year in your data table and the one selected by the user:
my issue is as below:
I hava a Calendar table with dates and Orders Table related to the Calendar table by DateID. I have slicer that allows user to choose month and year from a Calendar table so that the data will be shown only for the choosen month but on one bar chart i would like to show sum of orders by month (so month will be on X-axis) from Orders table not for one month but for the last 12 months where the last month is the one from the slicer. E.g. if user chooses 06-2107 from slicer then the bar chart should show orders data from 07-2016 till 06-2017. Obviously when the slicer and bar chart interact with each other i can see only one month.
I've tried to create a measure in DAX but I failed and the results are not what i expect. If the description is to messy i can provide the pbix file as an example