Time slicer in PowerBI - powerbi

This is sample of values appearing in my time custom column:
Part of formula that generated this custom column goes like this:
RETURN FORMAT( TIME(hr; mn;ss); "HH:mm:ss" ))
so this column suppose to be in "time" format.
But in visuals this column is recognized as text with discrete values. Is there a way to define it as time and use it as slicer/filter which is time based?

In the modeling tab, make sure the data type for your calculated column is set to 'Time'.

Related

PowerBI - Draw Line Chart with X Axis Grouped by Date (in Days), When Column contains Full timestamp?

I've been trying to figure this for several hours now.
In my SQL table I have a full timestamp column, with date and time of the action, e.g. last time a user was logged in.
Say I have two users who logged in today so far, in different hours. I want to see "2" log ins for today's Date, instead of seeing them broken down further into exact timestamps.
See screenshot for example
What's the easiest way to do this?
EDIT:
Seems like the whole issues stems from my desire to use "Direct Query" method to load the data.
If I'm just importing the whole table (as users_table (2)), Then yes, I can create a new column with this syntax:
Column = 'users_view (2)'[last_active].[Date]
And plot the graph that I Want.
However, I am unable to create this column on direct query mode. Trying to create this column leads to an error:
Column reference to 'last_active' in table 'users_view' cannot be used
with a variation 'Date' because it does not have any.
If such basic functinoally is not possible, then what's the merit of Power BI? my use case is to create a REAL time dashboard.
Seems like if I want to have anything in real time, it means I can't build even the most basic graph, and vice-versa.
So either I'm missing something, or Power BI is worthless for real time reporting.
You need to follow these steps:
In your fact table, create a new column that corresponds to the date of the timestamp (this will be a grouping dimension column for your timestamps)
Add a measure that counts rows of your table
In a new chart, e.g. line chart, bar chart, whatever - use the date column as X-axis information, and the row count measure as your Y-axis information
Edit: Since it is now apparent you insist on using Direct Query for this - it would appear your data is not in the correct format to support what you want to do. The solution would be to provide Power BI with the correct format for the analysis you want to do. Like adding a column in your SQL database table.
A very costly way of calculating "something" useful would be to do a cumulative count based on timestamp that resets daily. This will look messy but for a site with a lot of activity it will be able to plot something. But it will be slow - since obviously we are far, far away from what would constitute a "sensible" use-case for Power BI using Direct Query.
Cumulative Daily Logins =
VAR _max_time = MAX ( users_table[last_active] )
VAR _date = DATEVALUE ( _max_time )
RETURN
COUNTROWS (
FILTER (
ALL ( users_table ) ,
users_table[last_active] <= _max_time
&& DATEVALUE ( users_table[last_active] ) = _date
)
)

Converting decimal time to hours to plot a 24-hour timeline chart in power bi

hope you're doing well.
I'm a newbie to PowerBI and I'd want to convert the decimal time/date column values into hours of the time to plot the info over a 24-hour timeline. I was able to achieve this in tableau and as it automatically detects the hours and can easily be able to plot the info. I was a bit close in achieving this in powerBI as I converted the date/time column to time and tried plotting but there's huge noise and looks more cluttered as it took every change in seconds/minutes (the bottom snippet). I've attached the snippets for reference, can anyone pls try to help me on this ?
In Power BI it's recommended to split the DateTime column into separate Date and Time columns. This is both for performance reasons. Over a year a DateTime column with 1sec granularity can have 30M different values, which is much more data than storing one column with 365 values, and one with 86,400 values. And so that your Date column can link to a Date Dimension to provide other DateTime hierarchy attributes, like FiscalQuarter, DayOfWeek, etc.
In Power Query select the DateTime column and go to --> Add Column --> Time -- > Time Only. Then change the data type of the DateTime column to Date.
This also solves your reporting problem as you can simply put the Time column on the X axis.
If you want a custom format string for the time you can add a calculated column in Power Query like
= Table.AddColumn(#"Changed Type1", "TimeDesc", each DateTime.ToText(#date(2020,1,1)&[Time], [Format="h tt"]))
And configure the new column with a "Sort by Column" of Time.

Zulu time conversion in a calculated table

I'm using PowerBI to build a calculated table to do time calculation on an existing table.
calc_issues = CALCULATETABLE(
SELECTCOLUMNS('public issues', "created_at_dt", 'public issues'[created_at], "closed_at_dt", 'public issues'[closed_at]))
Both these columns are text in my original database and are imported as text in this calculated table. When I try to switch this calculated table into a Date/Time I get the following issue:
Cannot convert value '2021-09-09T14:55:11Z' of type Text to type Date while processing column.
Now if I go into my database table and convert the text into Date/Time there's error. But I want this new calculated table to show specific Date/Time calculations.
When I try to create a new column and try to do a DATEVALUE on the text I get the same error.
Solution: Power Editor doesn't modify the existing database table when using direct.
The query editor can be used to convert the text into time stamps. I loaded your data sample into Power Query in a blank query and it was converted automatically, even converting Zulu to my local time.
If you don't want to convert to local time, then remove the Z from the text by extracting the first 19 characters of the text, then change the data type.

Dynamic filtering based on selected value in slicer in Power BI

I am trying to create a calculated table where the data is being taken from another table and calculating the average based on the username, total average and variance between the 2 of these columns.
To create a table, I used the below DAX in Power BI which calculated the average based on the username.
scanner_speed_average_calculation =
SUMMARIZE(scanner_speed
,scanner_speed[user_name]
,"Average"
,AVERAGE(scanner_speed[order_processed]))
To calculate the group_average I used the below DAX:
group_average =
SUMMARIZE(
scanner_speed
, "Group Avg"
, average(scanner_speed[order_processed]))
And finally to calculate the variance, I used this query:
Variance = scanner_speed_average_calculation[Average] - scanner_speed_average_calculation[group_average]
Below is an outcome of these calculations.
I want to be able to make these calculations dynamic based on the selected value from the date. The table where I am taking these calculations do have the date value. I want to be able to use date range in slicer and I want these values to change based on the selected date range. I tried few things with Filter, Selectedvalue but I am not sure if I used them correctly.
Below is a main table where I took all these calculations from.
Below is a visual of where I want to group_average and variance. I want to be able to use date range and these columns should change accordingly.
Any idea or help will be appreciated. If possible then please put the entire formula. I am still a newbie in the world of DAX. Thanks in advance
power bi file
If you want a calculation to depend on a slicer, you need a Measure, not a calculated column or calculated table. Calculated columns and calculated tables are generated on refresh and physically stored in your model, so the slicers can filter them, but the slicers can't change the value of the calculations.
Measures are not persisted, but are calculated as needed based on changes to filters and slicers.
If you simply add add a measure
AverageOrdersProcessed := AVERAGE(scanner_speed[order_processed])
and put that on a visual that groups by user_name, you will get a the AVERAGE(scanner_speed[order_processed]) for each `user_name'.

SSAS Tabular/PowerBi - it's possible to convert unit to a K format in a chart in PowerBI?

I am creating measures in SSAS Tabular, i want to change my numbers to a k format.
For example if i have :
Measure1 := SUM(Turnover$) =100.000
I want to have in PowerBi : 100k
i have tried the format function in dax :
Measure1 := FORMAT(SUM(Turnover$);"#,.0k").
That works in PowerBI but only for the table/Matrix/Card, that won't work for a chart (can't put my measure in the values field ).
So i was wondering if it's possible to auto-format a number and to put in a chart.
you don't need to use the FORMAT function at all. Keep the measure numeric:
Measure1 := SUM(Turnover$) put it in the line/column visual and then in the formatting options of the visual go to the Data label section and change display units to Thousands