Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi everyone,
I'm having trouble with DAX and I was hoping someone could help me out. My issue is that if there isn't a date filter, I want the DAX code to use the code date filter. However, if there is already a date filter in a table, matrix, or slicer, I want the measure to use that date filter instead.
I've tried using Chat GPT and other solutions, but unfortunately, they didn't work for me. If anyone has any ideas or suggestions, I would greatly appreciate it. Thanks in advance!
Currently, the filter is set to calculate the results for the current month -1, which works fine for January. However, users sometimes need to find data for different dates, and that's where the problem arises.
To make matters more complicated, I also have other measures that rely on the same principle.
Thanks
BS Periodic Amounts = ABS(CALCULATE(
SUM('Fact'[Debit Amount])-SUM('Fact'[Credit Amount]),
'Fact'[G_L Account No_] >= 100 &&
'Fact'[G_L Account No_] <= 499 &&
YEAR('Fact'[Posting Date]) = YEAR(TODAY()) &&
MONTH('Fact'[Posting Date]) = MONTH(TODAY())-1
)
)
@Chelly , Please Try the current/last month using time intelligence
MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))
last month Sales = CALCULATE(SUM(Sales[Sales Amount]),previousmonth('Date'[Date]))
MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))
last month Sales = CALCULATE(SUM(Sales[Sales Amount]),previousmonth('Date'[Date]))
Time Intelligence, Part of learn Power BI https://youtu.be/cN8AO3_vmlY?t=27510
Time Intelligence, DATESMTD, DATESQTD, DATESYTD, Week On Week, Week Till Date, Custom Period on Period,
Custom Period till date: https://youtu.be/aU2aKbnHuWs&t=145s
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 66 | |
| 47 | |
| 41 | |
| 36 | |
| 23 |
| User | Count |
|---|---|
| 189 | |
| 124 | |
| 106 | |
| 78 | |
| 52 |