Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi,
I'm trying to determine which branches had transactions in a specific month but had no transactions in the next month using the following DAX. but whenever I tried it, it gave a blank or no data ( no error within the Dax):
A calculated table cannot take into account any slicers or filters, it is only calculated during data refresh.
You could create a measure to return 1 if the branch had transactions in the selected month but not the prior month, and use that as a filter on the visual. If you have a measure [Transactions] which returns the number or value of transactions, you could use
BranchesLastMonthNoThisMonth =
IF (
ISINSCOPE ( _2024[Branch] ),
VAR CurrentMonth = [Transactions]
VAR PrevMonth =
CALCULATE ( [Transactions], DATEADD ( 'Calendar'[Date], -1, MONTH ) )
VAR Result =
IF ( ISBLANK ( CurrentMonth ) && NOT ISBLANK ( PrevMonth ), 1 )
RETURN
Result
)
Hi @TamerOmki
Your DAX formula is close but has a few issues related to date filtering that may be causing the blank results. Specifically, the date ranges you’re using in FILTER may not correctly isolate transactions from just the previous and current month. Here’s an alternative approach that should work better.
Here’s how you could rewrite your measure:
BranchesLastMonthNoThisMonth =
VAR CurrentMonthBranches =
CALCULATETABLE(
VALUES(_2024[Branch]),
_2024[Transaction] <> BLANK(),
FILTER(
ALL('Calendar'),
'Calendar'[Date] >= STARTOFMONTH(MAX('Calendar'[Date])) &&
'Calendar'[Date] <= ENDOFMONTH(MAX('Calendar'[Date]))
)
)
VAR PreviousMonthBranches =
CALCULATETABLE(
VALUES(_2024[Branch]),
_2024[Transaction] <> BLANK(),
FILTER(
ALL('Calendar'),
'Calendar'[Date] >= STARTOFMONTH(DATEADD(MAX('Calendar'[Date]), -1, MONTH)) &&
'Calendar'[Date] <= ENDOFMONTH(DATEADD(MAX('Calendar'[Date]), -1, MONTH))
)
)
RETURN
EXCEPT(PreviousMonthBranches, CurrentMonthBranches)
This approach should resolve the issue and return the expected list of branches. Let me know if it works or if you need further adjustments!
Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂
Kind Regards,
Poojara
Data Analyst | MSBI Developer | Power BI Consultant
YouTube: https://youtube.com/@biconcepts?si=04iw9SYI2HN80HKS
Hi @Poojara_D12
Thanks a lot for your kind reply, but whenever I tried to apply this DAX I got this error "The first argument to 'STARTOFMONTH' must specify a column."
can you help please ...
Thanks once again
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
10 | |
10 | |
10 | |
9 | |
7 |
User | Count |
---|---|
17 | |
12 | |
11 | |
11 | |
10 |