This document details a DAX function for calculating daily costs from entries in a SharePoint list. It creates an output table with costs for specified date ranges, ensuring accurate financial tracking and visualization in Power BI.
This document outlines a DAX function to calculate the cost per day based on the cost per day entries from a SharePoint list, encompassing the given date range.
StartDate
, EndDate
, and CostPerDay
.The function will:
CostPerDay
.DailyCosts =
VAR DateRangeStart = DATE(2023, 1, 1) // Adjust the start date as needed
VAR DateRangeEnd = DATE(2023, 1, 31) // Adjust the end date as needed
RETURN
ADDCOLUMNS(
CALENDAR(DateRangeStart, DateRangeEnd), // Create a calendar table for the date range
"Daily Cost",
VAR CurrentDate = [Date]
VAR CostRecord =
FILTER(
SharePointList, // Replace with your actual SharePoint list name
CurrentDate >= [StartDate] && CurrentDate <= [EndDate]
)
RETURN
IF(
COUNTROWS(CostRecord) > 0,
SUMX(CostRecord, [CostPerDay]), // Summing the CostPerDay for valid date ranges
BLANK() // Return BLANK if no cost record found for the date
)
)
Date Variables:
DateRangeStart
and DateRangeEnd
specify the range for which we are calculating the costs.CALENDAR Function:
DateRangeStart
to DateRangeEnd
.ADDCOLUMNS Function:
FILTER Function:
IF Statement:
StartDate
and EndDate
from the SharePoint list are valid date types.To utilize the DailyCosts
calculation in a Power BI report or dashboard, you can create a visual using the output table displaying Date
and Daily Cost
.
When you compute costs from 2023-01-01
to 2023-01-31
, the results will yield:
2023-01-01
to 2023-01-02
: $100 per day.2023-01-03
to 2023-01-05
: $100 per day + $150 per day for 2023-01-03
to 2023-01-10
.This example will successfully yield the daily costs dynamically across your visualizations based on your datasets.
This DAX function efficiently calculates daily costs from a SharePoint list and can be extended or modified to cater to more complex requirements. For advanced learning on DAX functions, consider exploring courses on the Enterprise DNA Platform.
This document details a DAX function for calculating daily costs from entries in a SharePoint list. It creates an output table with costs for specified date ranges, ensuring accurate financial tracking and visualization in Power BI.