Time Intelligence Functions() |Power BI || Belayet Hossain
Belayet Hossain ??
Power BI Developer @ZnZ | Data Analyst | SQL, Python, ETL, DBMS, DAX | Find insight & Making Decision|| Ex-Head of Quality Dept & 09 Y With smartphone Manufacturing & Service | Ex- RFL, VIVO, Symphony || EEE
Time Intelligence functions are used to analyze and compare data over different periods (e.g., year-to-date, quarter-to-date, month-to-date). Here's a detailed explanation of each Time Intelligence Function in Power BI. The explanation includes Purpose, Use, Syntax, Example, Scenario, Relevant DAX, and Comparative Differences.
?
?? 1. CALENDAR()
Scenario: We want to create a custom date range from January 1, 2023, to December 31, 2023, for reporting purposes.
DAX: CALENDAR(DATE(2023, 1, 1), DATE(2023, 12, 31))
CALENDARAUTO() automatically detects the date range from the model, while CALENDAR() requires you to manually input the start and end dates.
??2. CALENDARAUTO()
Scenario: If our dataset contains data from 2022 to 2023, this function will create a date table from January 1, 2022, to December 31, 2023.
DAX : CALENDARAUTO()
CALENDAR() requires start and end dates, while CALENDARAUTO() figures it out based on the data.
??3. DATESYTD()
Scenario: We want to analyze all cost data for the current year up to today's date.
DAX: Costs (DATESYTD) = CALCULATE([Total cost (ALL)], DATESYTD('calendar'[date]))
??4. DATESQTD()
Scenario: You want to analyze the Sold Quantity data for the current quarter.
DAX: Qty Sold (DATESMTD) = CALCULATE([Total Qty], DATESQTD('calendar'[date]))
??5. DATESMTD()
Scenario: We want to analyze the Sold Quantity data for the current month.
Here We have used DATEMTD() function to calculate the cumulative Sold quantity for the month. for that we can see after completing January month again started cumulative sum from the 1st of February Month.
Similarly DATESYTD() will cumulative sum within a year then It will start cumulative sum from the 1st of next year.
DATEQTD() will do same for Quarter wise.
??6. TOTALYTD()
Scenario: We want to calculate total cost up to today's date for the year.
DAX: Costs (TOTALYTD) = TOTALYTD([Total cost (ALL)], 'calendar'[date])
领英推荐
??7. TOTALQTD()
Scenario: We want to calculate the total cost for the current quarter.
DAX: Costs (TOTALQTD) = TOTALQTD([Total cost (ALL)], 'calendar'[date])
??8. TOTALMTD()
Scenario: You want to calculate the total Sold Quantity for the current month.
Here We have used TOTALMTD() function to calculate the cumulative total Sold quantity for the month. for that we can see after completing January month again started cumulative sum from the 1st of February Month.
Similarly TOTALYTD() will cumulative sum within a year then It will start cumulative sum from the 1st of next year.
TOTALQTD() will do same for Quarter wise.
?? 9. DATESINPERIOD()
Scenario: We want to analyze each next 5 days of Costs data starting from the 1st days of data.
Here, DATESINPERIOD() used to calculate the running total of a cost over the last 5 days, ending on the current date (or the maximum date in the data context).
?? 10. PARALLELPERIOD()
Scenario: We want to compare cost from the same period last Month.
Here, The DAX expression uses the PARALLELPERIOD() function along with CALCULATE() to compute the total costs for the previous month. (e.g., for March, it will show February’s costs).
??11. SAMEPERIODLASTYEAR()
Scenario: We want to compare this year’s sales to the same period last year.
?? 12. DATEADD()
Here, This DAX formula is calculating with DATEADD () function the total cost for the previous day based on the current context of dates
??Comparative Difference:
#powerbi #timeintelligence #functions #powerbideveloper