Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hey guys,
I am a new Power BI user and I'm stumped by this problem.
I'm trying to calculate the sum of invoice values in a sales table against the current date in a custom fiscal quarter (June-April FY).
My date table has columns outlining the fiscal quarter, fiscal startofquarter, and fiscal endofquarter. I had an idea to add IF statements to try determine what quarter today's date falls into.
I've tried writing the DAX function below but i'm getting errors:
ActualQTD = CALCULATE([Net Amount], DATESBETWEEN( 'Date', IF('Date'[Date] = TODAY(), 'Date'[Fiscal StartOfQuarter]), IF('Date'[Date] = TODAY(), 'Date'[Fiscal EndOfQuarter]) ) )
What can I do to make this work? Any hint in the right direction would be amazing, thank you.
Solved! Go to Solution.
Hey @Phil_Seamark,
So I managed to figure this out.
It helped that I was using SQLBI's Dax Date table, which includes a date for the start/end of fiscal quarter, month and year.
I began by creating the following measures:
Start Of Fiscal Quarter = CALCULATE(MIN('d Date'[F.QuarterStart]), ('d Date'[date] = TODAY()))
End Of Fiscal Quarter = CALCULATE(MIN('d Date'[F.QuarterEnd]), ('d Date'[date] = TODAY()))
I then employed the DATESBETWEEN FUNCTION in the following measure:
ActualQTD = CALCULATE([Net Amount], DATESBETWEEN( 'd Date'[Date], [Start Of Fiscal Quarter], [End Of Fiscal Quarter] ) )
Doing this has allowed The Actual QTD number to stay current based on the current quarter. I repeated this for the fiscal month and year it all worked out nicely.
Cheers,
Hi @Anonymous
Does this slight mod help?
ActualQTD = TOTALQTD([Net Amount],'Date'[Date])
Hey @Phil_Seamark, this is almost exactly the DAX statement I had before.
What i had before was this:
ActualQTD = CALCULATE([Net Amount], DATESQTD('Date'[Date]))
The problem here is that the DATESQTD function is based on the calendar year, and not the Fiscal (at least, I think that's the case).
The error I'm receiving from PBI for the original DAX function I wrote is this:
*DatesBetween and DatesInPeriod functions are only accepting date column reference as a first argument*
Hey @Phil_Seamark,
So I managed to figure this out.
It helped that I was using SQLBI's Dax Date table, which includes a date for the start/end of fiscal quarter, month and year.
I began by creating the following measures:
Start Of Fiscal Quarter = CALCULATE(MIN('d Date'[F.QuarterStart]), ('d Date'[date] = TODAY()))
End Of Fiscal Quarter = CALCULATE(MIN('d Date'[F.QuarterEnd]), ('d Date'[date] = TODAY()))
I then employed the DATESBETWEEN FUNCTION in the following measure:
ActualQTD = CALCULATE([Net Amount], DATESBETWEEN( 'd Date'[Date], [Start Of Fiscal Quarter], [End Of Fiscal Quarter] ) )
Doing this has allowed The Actual QTD number to stay current based on the current quarter. I repeated this for the fiscal month and year it all worked out nicely.
Cheers,
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
111 | |
94 | |
83 | |
66 | |
59 |
User | Count |
---|---|
151 | |
121 | |
104 | |
87 | |
67 |