Daily DAX : Day 169 MINUTE
The MINUTE function in Power BI DAX (Data Analysis Expressions) is a time-intelligence function that extracts the minute component from a given time or datetime value. It returns an integer between 0 and 59, representing the minute of the hour.
Syntax
MINUTE(<datetime>)
<datetime>: A column reference, expression, or value that returns a datetime or time value. This is the input from which the minute is extracted.
Return Value
An integer from 0 to 59, corresponding to the minute portion of the provided datetime.
How It Works
The MINUTE function takes a datetime value and isolates the minute part of it. For example:
If the input is 2025-03-30 14:45:00 (2:45 PM), the function returns 45.
If the input is 09:05:00 (9:05 AM), it returns 5.
If the input is a date without a time (e.g., 2025-03-30), the time is assumed to be midnight (00:00:00), and the function returns 0.
Use Case
The MINUTE function is particularly useful in scenarios where you need to analyze or aggregate data based on the minute component of a timestamp. Here are some practical examples:
Time-Based Analysis:
Suppose you have a dataset of customer transactions with timestamps. You can use MINUTE to extract the minute of each transaction and analyze patterns, such as peak activity minutes within an hour.
Conditional Formatting or Filtering:
You might want to filter or highlight records that occur within a specific minute range (e.g., events happening between the 30th and 45th minute of every hour).
Creating Custom Time Segments:
Combine MINUTE with other DAX functions like HOUR or SECOND to create custom time buckets or segments for reporting (e.g., grouping data into 15-minute intervals).
Scheduling and Logging:
In a dataset tracking system logs or scheduled tasks, you can use MINUTE to break down when events occur within an hour for detailed reporting.
Example in Power BI
Assume you have a table named Sales with a column TransactionTime containing datetime values. You can create a calculated column to extract the minute like this:
MinuteOfTransaction = MINUTE(Sales[TransactionTime])
Sample Data
TransactionTime MinuteOfTransaction
2025-03-30 08:15:23 15
2025-03-30 14:47:09 47
2025-03-30 23:00:00 0
You can then use this new column in visuals, filters, or calculations.
Practical Scenario
Imagine you're analyzing call center data and want to see how call volumes vary by minute within an hour. You could:
Extract the minute using MINUTE(CallData[CallTime]).
Create a bar chart with the minute on the X-axis and call count on the Y-axis to identify peak times (e.g., calls spiking at the 0th or 30th minute).
Notes
If the input to MINUTE is blank or invalid (e.g., not a datetime), it returns an error unless handled with functions like IFERROR.
It works only with datetime or time values—passing a text string like "14:30" directly won’t work unless it’s first converted to a datetime format.
The MINUTE function is a simple yet powerful tool for time-based analysis in Power BI, enabling granular insights into temporal data.
Comments
Post a Comment