Forum Discussion
Sum and filter
- 2 years ago
To calculate the net adds for the month based on filtering by the Start Date and Service End Date columns and summing the Quantity column in Power BI using DAX, you can create two measures and then calculate the net adds. Here’s how you can do it:
Step 1: Create Measure for Start Date Sum
First, create a measure to sum the Quantity column where the Start Date is in the selected month (e.g., October).StartDateSum =
CALCULATE(
SUM('YourTable'[Quantity]),
FILTER(
'YourTable',
MONTH('YourTable'[Start Date]) = MONTH(TODAY()) &&
YEAR('YourTable'[Start Date]) = YEAR(TODAY())
)
)
Step 2: Create Measure for Service End Date Sum
Next, create a measure to sum the Quantity column where the Service End Date is in the selected month (e.g., October).EndDateSum =
CALCULATE(
SUM('YourTable'[Quantity]),
FILTER(
'YourTable',
MONTH('YourTable'[Service End Date]) = MONTH(TODAY()) &&
YEAR('YourTable'[Service End Date]) = YEAR(TODAY())
)
)
Step 3: Create Measure for Net Adds
Finally, create a measure to calculate the net adds by subtracting the EndDateSum from the StartDateSum.NetAdds = [StartDateSum] - [EndDateSum]
To calculate the net adds for the month based on filtering by the Start Date and Service End Date columns and summing the Quantity column in Power BI using DAX, you can create two measures and then calculate the net adds. Here’s how you can do it:
Step 1: Create Measure for Start Date Sum
First, create a measure to sum the Quantity column where the Start Date is in the selected month (e.g., October).
StartDateSum =
CALCULATE(
SUM('YourTable'[Quantity]),
FILTER(
'YourTable',
MONTH('YourTable'[Start Date]) = MONTH(TODAY()) &&
YEAR('YourTable'[Start Date]) = YEAR(TODAY())
)
)
Step 2: Create Measure for Service End Date Sum
Next, create a measure to sum the Quantity column where the Service End Date is in the selected month (e.g., October).
EndDateSum =
CALCULATE(
SUM('YourTable'[Quantity]),
FILTER(
'YourTable',
MONTH('YourTable'[Service End Date]) = MONTH(TODAY()) &&
YEAR('YourTable'[Service End Date]) = YEAR(TODAY())
)
)
Step 3: Create Measure for Net Adds
Finally, create a measure to calculate the net adds by subtracting the EndDateSum from the StartDateSum.NetAdds = [StartDateSum] - [EndDateSum]