Daily DAX : Day 331 LCM
LCM Function in Power BI DAX
Description
The LCM
function in Power BI DAX calculates the Least Common Multiple of two integers. It returns the smallest positive number that is a multiple of both input numbers.
Syntax
LCM(number1, number2)
- number1: First integer number.
- number2: Second integer number.
Return Value
An integer representing the least common multiple of the two input numbers. If either input is not an integer, it is truncated to an integer. Returns an error if inputs are negative or zero.
Use Case
The LCM
function is useful in scenarios requiring synchronization or alignment of periodic events, such as:
- Scheduling Analysis: Determine when two recurring events (e.g., maintenance schedules or delivery cycles) will coincide.
- Financial Modeling: Align payment cycles or interest calculations that occur at different intervals.
- Data Aggregation: Combine datasets with different time granularities (e.g., daily and weekly data) by finding a common period.
Example
Suppose you have two processes: one runs every 6 days, and another every 8 days. To find when they next occur together:
CommonPeriod = LCM(6, 8)
Result: 24 (the processes align every 24 days).
Notes
- Inputs must be positive integers; otherwise, an error is returned.
- Non-integer inputs are truncated (e.g., 6.7 becomes 6).
- Use in calculated columns or measures for dynamic calculations in Power BI reports.
Comments
Post a Comment