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.
Hi,
I need to write dax to calculate cumulative total quarter wise, TOTALQTD function can work but as we are using live connection so time intelligence functions are not working. I have tried below DAX:
Solved! Go to Solution.
Hi @Anonymous ,
It is needed to use "FILTER" in you expression. Try this:
CumTotal =
CALCULATE (
SUM ( Table1[delta] ),
FILTER (
ALL ( 'Table1' ),
QUARTER ( Table1[DATE] ) <= QUARTER ( EARLIER ( Table1[DATE] ) )
)
)
Or this:
CumTotal =
CALCULATE (
SUM ( Table1[delta] ),
FILTER (
ALL ( 'Table1' ),
QUARTER ( Table1[DATE] ) <= QUARTER ( MAX ( Table1[DATE] ) )
)
)
Best Regards,
Icey
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous ,
It is needed to use "FILTER" in you expression. Try this:
CumTotal =
CALCULATE (
SUM ( Table1[delta] ),
FILTER (
ALL ( 'Table1' ),
QUARTER ( Table1[DATE] ) <= QUARTER ( EARLIER ( Table1[DATE] ) )
)
)
Or this:
CumTotal =
CALCULATE (
SUM ( Table1[delta] ),
FILTER (
ALL ( 'Table1' ),
QUARTER ( Table1[DATE] ) <= QUARTER ( MAX ( Table1[DATE] ) )
)
)
Best Regards,
Icey
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
to use the Max function you should use variables or place it first within a Filter function
@Anonymous ,
Try max, But datesqtd should have worked
SumTotal =
CALCULATE(Sum(Table1[delta]),
ALL('Table1'),QUARTER(Table1[DATE])=QUARTER(max(Table1[DATE])) && (Table1[DATE])=(max(Table1[DATE]))
)
This is way for non std qtr
new columns
Qtr Start Date = DATEADD(STARTOFYEAR('Date'[Date],"4/30"),QUOTIENT(DATEDIFF('Date'[Start Of Year], 'Date'[Date],MONTH),3)*3,MONTH)
Qtr Day = DATEDIFF('Date'[Qtr Start Date],'Date'[Date],Day)+1
Qtr Rank = RANKX(all('Date'),'Date'[Qtr Start date],,ASC,Dense)
measures
This Qtr = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Qtr Rank]=max('Date'[Qtr Rank])))
Last Qtr = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Qtr Rank]=max('Date'[Qtr Rank])-1))
This QTD = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Qtr Rank]=max('Date'[Qtr Rank]) && [Qtr Day] <=max([Qtr Day])))
Last QTD = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Qtr Rank]=max('Date'[Qtr Rank])-1 && [Qtr Day] <=max([Qtr Day])))
Hi @amitchandak ,
Thanks for the response!
I tried below DAX:
SumTotal =
CALCULATE(Sum(Table1[delta]),
ALL('Table1'),QUARTER(Table1[DATE])=QUARTER(max(Table1[DATE])) && (Table1[DATE])=(max(Table1[DATE]))
)
and came across below error:
A function 'MAX' has been used in a True/False expression that is used as a table filter expression. This is not allowed.
Can you please suggest.
when you work with time intelligence functions you must have a date table in the model.
also review the DatesQTD function https://docs.microsoft.com/en-us/dax/datesqtd-function-dax
Hi @jairoaol ,
Thanks for response!
We are using Live connection so Time intelligence functions are not supported. We need to write DAX with basic functions in Power BI. DatesQTD function is not working.
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 |
---|---|
113 | |
97 | |
85 | |
70 | |
61 |
User | Count |
---|---|
151 | |
121 | |
104 | |
87 | |
67 |