The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now
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,
User | Count |
---|---|
158 | |
109 | |
96 | |
84 | |
75 |
User | Count |
---|---|
157 | |
137 | |
131 | |
81 | |
61 |