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
I have a pickle that I'm struggling with and I need someone really competent in DAX to help me. I need one measure that is one thing if this month is selected, and another if we go back in time. It has to be one measure to allow the use of the same visual with a month selector.
So open amount is
=CALCULATE( SUM(OrderBook[Open amount]),LASTDATE('Date'[Date]))
if we select the current month
and
=CALCULATE( SUM(OrderBook[Open Amount]),LASTNONBLANK('Date'[Date],[OpenQtyNow]))
if we select a previous month.
I have tested the two separately and they do what I want, but I need them in one measure and I am not a DAX wizard (yet) 🙂
Solved! Go to Solution.
I ended up with this construct that yielded the required result (in case anyone with the same problem visits this post):
OpenamtNow =
CALCULATE( SUM(OrderBook[Open amount]),LASTNONBLANK('Date'[Date],
CALCULATE(SUM(OrderBook[Open amount]), FILTER( ALL('Customers'),1))
))
I ended up with this construct that yielded the required result (in case anyone with the same problem visits this post):
OpenamtNow =
CALCULATE( SUM(OrderBook[Open amount]),LASTNONBLANK('Date'[Date],
CALCULATE(SUM(OrderBook[Open amount]), FILTER( ALL('Customers'),1))
))
That looks good - however, it leaves the open amount for this month totally empty. Maybe I dreamt something up that is not doable. Let me ponder - I will supply a pbix for a more detailed problem description. Thank you anyway 🙂
Is your Date last date the same as your data last date?
For example my last sale could be 26/09/2024 but in my calendar table it would be 31/12/2024
If not that would explain the blank.
Swap measure =
If(
month(today()) = month(lastdate(OrderBook[OrderDate]))
,CALCULATE( SUM(OrderBook[Open amount]),lastdate(OrderBook[OrderDate]))
,CALCULATE( SUM(OrderBook[Open Amount]),LASTNONBLANK('Date'[Date],[OpenQtyNow]))
)
If you are happy with this answer please mark as a solution for others to find !
Kudos are always appreciated! Check out our free Power BI video courses.
That makes perfect sense. So I apply my data date as follows:
Hi @Cadenze
Not sure I 100% understand what you are asking but I will have a go!
Swap measure =
If(
month(today()) = month(lastdate(date[date]))
,CALCULATE( SUM(OrderBook[Open amount]),LASTDATE('Date'[Date]))
,CALCULATE( SUM(OrderBook[Open Amount]),LASTNONBLANK('Date'[Date],[OpenQtyNow]))
)
If you are happy with this answer please mark as a solution for others to find !
Kudos are always appreciated! Check out our free Power BI video courses.
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
Check out the November 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 59 | |
| 43 | |
| 42 | |
| 23 | |
| 17 |
| User | Count |
|---|---|
| 190 | |
| 122 | |
| 96 | |
| 66 | |
| 47 |