Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
I have a table of data that looks something like this mockup
I have a measure to calculate the starting balance for as of the max Period_Begin_Date for each ag_level group like this:
But when I change the column to the Month-Year field (which is a formula based on period begin date) it produces blanks like this:
Can someone help me understand how to make the formula work using the month-year field instead of the period end date in the formula, or just explain WHY it gives blanks so I can understand these dax formulas better? Thank you in advance.
Hi @lauriemclolo ,
Just checking in to see if the solution I shared helped resolve the issue on your end. As mentioned, converting the Month-Year text to a proper date column and sorting it by the real month start date usually addresses the blank or sorting issues in time-based visuals. If it worked well great! If not, I’d be happy to take a look.
Regards,
Akhil
Hi @v-agajavelly Sorry for the delay. Was out of town. Regretfully it still gives blanks for the starting balance when I use your formula. Also, the expected outcome is showing in my original screenshot. I don't know how to provide data that is both in usuable format and not contain sensitive data.
Hi @lauriemclolo
Thanks for clearly explaining the issue. You were absolutely on the right track with your DAX for the Starting Balance. The reason you were getting blanks when switching to Month-Year was because that field was a text string, and DAX couldn't evaluate conditions like <= MaxDate against it properly.
According to your ask I recreated your scenario in Power BI and here’s exactly what worked. First created a Proper Month Column and Instead of using Month-Year as a text column, I created a real date field that represents the start of each month.
MonthStart = DATE(YEAR([fiscal_period_begin_date]),MONTH([fiscal_period_begin_date]), 1)
Then, for cleaner visual display, I have added Month column by using bellow measure.
Month = FORMAT([MonthStart], "MMM YY")
If required you need to sort, I sorted the Month column by the real MonthStart date.
Column tools → Sort by column → MonthStart
This ensures months appear in correct order (Jan, Feb, Mar...) rather than alphabetically. I’ve attached a working .PBIX along with snip file here so you can open it and see the setup in action. Feel free to reuse or adapt it as needed for your real data.
If still the above solution won't helps, to assist you effectively, could you please share sample data that fully illustrates your issue or question? We kindly request that the data be provided in a usable format (rather than as a screenshot) and that it does not contain any sensitive information or unrelated content.
Additionally, it would be helpful if you could include the expected outcome based on the sample data you provided.
Regards,
Akhil.
Hi @lauriemclolo ,
The issue you are encountering is a classic DAX challenge rooted in how filter context operates within Power BI visuals. When your report visual uses the full period_begin_date in its columns, each column has a filter context for a single day, for example, period_begin_date = April 06, 2025. Your original DAX formula works here because the ALL(v_tcp_aggr_point[period_begin_date]) function successfully removes that single-day filter, allowing it to look at all previous dates to calculate the starting balance. However, when you switch the visual to use the Month-Year field, the context fundamentally changes. For a column like "Apr-2025", the entire data table is filtered to only include rows where the month is April. Your DAX measure attempts to remove the filter from the period_begin_date column, but it does not remove the persistent filter on the Month-Year column. Consequently, the calculation is trapped within the month of April and cannot "see" the data from March, February, or earlier, which is necessary to compute a starting balance. This inability to access prior months is why the measure returns blank values.
To solve this, the measure must be rewritten to first identify the time period it's in, then explicitly remove all surrounding filters to look back in time. The logic should be to determine the very first day of the month defined by the column's context (e.g., April 01, 2025) and then calculate the sum of all transactions that occurred before that day. It is also worth noting that a balance is typically calculated as inflows minus outflows. Your original formula adds all point values together. The formula below uses a more standard balance calculation of (Earned + Returned) - (Redeemed + Expired), which you can adjust if your business logic is different.
Starting Balance Monthly =
VAR LastDateInMonth =
MAX ( v_tcp_aggr_point[period_begin_date] )
VAR FirstDayOfCurrentMonth =
STARTOFMONTH ( LastDateInMonth )
RETURN
CALCULATE (
[Total Points Earded] + [Total Points Returned] - [Total Points Redeemed] - [Total Points Expired],
FILTER (
ALL ( v_tcp_aggr_point ),
v_tcp_aggr_point[period_begin_date] < FirstDayOfCurrentMonth
)
)
This corrected measure first finds the latest date within the current context (e.g., some day in April 2025) and uses STARTOFMONTH to establish the first day of that month as a boundary. The key to the solution is inside the CALCULATE function. By using FILTER(ALL(v_tcp_aggr_point), ...) it strips away all existing filters from the table, including the Month-Year = "Apr-2025" filter that caused the original problem. Once all data from all time periods is visible, it applies a new filter to sum only the transactions where the date is strictly less than the first day of the current month. This correctly computes the cumulative total up to the end of the previous month, providing the accurate starting balance for the month in the column.
As a final point of best practice, handling time intelligence calculations like this is made significantly easier and more efficient by creating a dedicated Date Table in your model. You would create a table with a continuous sequence of dates and columns for Year, Month, Month-Year, etc. After creating a relationship from this new table to your v_tcp_aggr_point table, you would use the columns from the Date Table in your visuals. This approach simplifies DAX and improves performance, as removing filters from a small, dedicated Date Table is more efficient than removing them from your entire, much larger data table.
Best regards,
@DataNinja777 Thank you for this, but I'm getting the error "The first argument to 'STARTOFMONTH' must specify a column." Period begin date is a date column so startofmonth is referencing a date in it's formula. Can you help?
Hi,
Share some sample data to work with and show the expected result. Share data in a format that can be pasted in an MS Excel file.
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
75 | |
72 | |
39 | |
29 | |
27 |
User | Count |
---|---|
97 | |
96 | |
58 | |
44 | |
40 |