Trying to make a date slicer which includes both date and time - powerbi

I have a table of many datetime datapointname value triplets from process probe sensors.
I want to have a slicer which I can use to pick from time1 on day 1 to time2 on day 2
So my approach has been to have three slicers [Time Start] [Date Slicer] [Time End]. I have the data table and two time tables in 30 minute intervals so I have been able to create measures and display cards to show on the report the start and stop datetime combo.
I try to combine all this into a new table using DAX which filters the data table using the measures that I have but have not had any success.
Does anyone how how to set up a slicer or set of slicers so I can filter my report (for example), from 2022-Jun-15 at 4:30 PM to 2022-Jun-18 at 10:00 AM?
I am just learning about DAX. I have spent a few hours at this with no sucess.
Thanks

That's probably not a good idea from a modelling perspective. Data modelling best practice suggests that your Date (where 1 row = 1 day) and Time (where 1 row = 1 second or 1 minute, as necessary) dimension tables should be separate.
I would therefore recommend you setup your model in such a way that you have these two dimensions as two separate tables. You should then just be able to have two slicers - one from each table - to do what you need.
Note: this of course means that your fact tables will need to have separate columns (one for the date and one for the time) to join to your Date and Time dimension tables.

Related

Add missing month rows based on multiple columns with multiple variables in Power BI

I'm very stuck and I was hoping you can help. So have the following dataset (Table 1) with Month (5 years worth), Customer (1000 customers), Product (100 products), Units and Value (value is just unit multiple a price). The data only shows rows with unit and value, so for customers when there is no sale in a month, there is no data.
Click here for Table 1
I want to create a table (Table 2) where every product for every customer is shown for all time periods, where actual units and values are included and those missing in Table 1 are now showing 0.
Click here for Table 2
I have read many posts here and elsewhere, which only handles 1 column (e.g. only Customer not both Customer AND Product, and only 1 measure not Unit and Value). I tried to adapt the code but failed miserably.
I also want to do this in Power BI using M not DAX, because I would like to further transform the data.
Thank you so much everyone!!!
Good afternoon.
You can use DAX to create a calendar for the required period of time.
Use the minimum and maximum values from Table 1 for the interval (Calendar function).
Calendar = CALENDAR(Date(2022,5,1), TODAY() -1)
Link the calendar to the necessary dates.
calendar link example
In the settings of the table to which you will output data, select the "Show items without data" setting, and take the date from the calendar.

Power BI Divide two measure from different tables and show in a graph with time

I have two tables, Table one has daily data, Table two has weekly data. I've created a start of week column in Table 1 to get weekly data. Data is as shown below :
I want to create a table where I can divide these two measures. Both measures are counts in a week. I want to present this in a line/bar chart with time at the x-axis. Right now when I use the Date of Table 1, My measure 2 takes the overall count as the date of table 2 is not present and vice versa. I was thinking of creating a new Calendar table but I'm unable to get these measure values in that table.
I tried creating a custom calendar table but I'm not getting the desired result. I'm getting correct values from table 2 but no values from table 1. I feel the problem is because table 1 has duplicate date values.
Table 1 actual data before consolidation:Measure is the count of case numbers
I think you need a slight paradigm shift in your thinking, potentially.
Rather than looking for a way to create a third table from two other tables, what you should do is create a relationship between the two tables to make a rational description of how you want these tables to work, and then write the DAX on top of it.
So, in your case, you describe one table having daily data, and the other having weekly. The intermediary calendar table would be a daily calendar, where each day (row) knows the end of week date.
You would then create a relationship from your daily table to the calendar table based on day, and create a second relationship to your weekly table based on end of week date. (assuming bi-directional filtering)
You could then create a measure:
myRatio = DIVIDE(SUM(DailyTable[value]), SUM(weeklyTable[value])
In your chart, you can then show the daily value as a fraction of the weekly value by using the 'Day' field from the calendar table, or you could show the ratio of the complete week from the daily table to the weekly total in the weekly table by using the end of week date in the chart.
If what you truly need is a 3rd table, then you could use the SUMMARIZE() function on this 3 table set to do the summarization into a 3rd table using the same principle.
myNewTable =
SUMMARIZE(calendarTable
,calendarTable[End of Week Date]
,"My Ratio" //the name of the field you want to create
,[My Ratio] //the formula to describe what goes in the field
)

Create a pivot table in Power BI with dates instead of aggregate values?

I have a table of companies with descriptive data about where we are in the sales stage with the company, and the date we entered that specific stage. As can be seen below, the stages are rows in a Process Step column
My objective is to pivot this column so each Process Step is a column, with a date below it, as shown in excel:
I tried to edit the query and pivot the column upon loading it, but for the "aggregate value" column, no matter which column I use as the values column, it results in some form of error
My advice would be not to pivot the table in the query and use measures to get dates that you want. The benefit of not doing so is that you are able to perform all sorts of other analytics. For instance, Sankey chart would be hard to do properly with pivoted table.
To get the pivot table you are showing from Excel, it's as simple as using matrix visual in Power BI and putting Client code in rows and Process Step in Columns, then Effective date in values.
If you need to perform calculations between stages, it's also not too difficult. For instance, you can create a meausure that shows only dates at certain stages, another measure for another stage, and so on. For example:
Date uploaded = CALCULATE(MAX(Table[Effective Date]), FILTER(Table, Table[Process Step] = "Upload"))
Date exported = CALCULATE(MAX(Table[Effective Date]), FILTER(Table, Table[Process Step] = "Export"))
Time upload to export = DATEDIFF([Date uploaded], [Date exported], DAY)
These measures will work in the context of client and assuming there is only one date for the upload step (but no Process step in rows or columns). If another scenario is needed, perhaps a different approach could be taken.
Please let me know if that solves your problem.

How to filter dates 2 days before today

Table has a column with dates. I am showing this data with Table visualization. I need to filter the date to always show dates that are 2 days before from now. For example today is 22.04.2020 and I need to filter it so it would automatically show only data with dates 2 days before like 20.04.2020 as a max date. In SQL I use codeDATEADD(DAY, -1, #today)
Since I'm using direct query then I can't make changes to the date table in query manager ( It needs to be updated every 15 minutes )
How can I do that in Power BI visualization?
Very simple, use relative filtering.
You can define it as a slicer, a hidden slicer or in the filter panel.

How can I get the number of days by month from a slicer in Power BI?

I just want to select a range of days in a slicer and show in a table the number of days for each month/period (month-year).
I used DAX to create a table with the information I need and I don't have problems with the periods (first column), it changes dinamically, the problem is the column "Days" (second column) because it's always showing the total number of days for each month.
Here my DAX code
SelectedPeriods = GROUPBY(DimDate;DimDate[Period];"Days";COUNTX(CURRENTGROUP();DimDate[DateKey]))
Here the result
What I expect is:
2 for april, 31 for may, 1 for june
This is an issue with execution order.
SelectedPeriods = GROUPBY(DimDate;DimDate[Period];"Days";COUNTX(CURRENTGROUP();DimDate[DateKey]))
Generates a calculated table. These are calculated when the data model is refreshed and stored in it. They are not refreshed each time a connected dimension is changed within a dashboard.
In your case, while changing date filters may hide rows from this table the number of days remains fixed at the number calculated initially when there was no filter context on the data i.e. counting all days in the month.
If you want the result to change then you need to use a measure instead of a calculated table. Measures react to the current filter context within the report and so will adjust their output each time a slicer is changed.
The needed measure will depend on your model but might be something as simple as:
CountOfDays := CountRows(DimDate)