Forum Discussion
Current vs Previous Quarter Sales
- Anonymous4 years ago
Hi Jos13 ,
To achieve this, you need to create a new seperate calculated table.
Quarter = DISTINCT('Sales'[Quarter])The quarter table has no relationship with the main table.
In the sales table, I have expanded some data to increase the situation in different years.
Create two measures
CQ Sales = var _cq=SELECTEDVALUE('Quarter'[Quarter]) return CALCULATE(SUM('Sales'[Sales]),FILTER('Sales',[Quarter]=_cq))PQ Sales = var _cq=SELECTEDVALUE('Quarter'[Quarter]) var _pq=IF(VALUE(RIGHT(_cq,1))=1,VALUE(LEFT(_cq,4))-1&" Q4",LEFT(_cq,4)&" Q"&VALUE(RIGHT(_cq,1))-1) RETURN CALCULATE(SUM(Sales[Sales]),FILTER('Sales',[Quarter]=_pq))Here's the results.
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Jos13 ,
To achieve this, you need to create a new seperate calculated table.
Quarter = DISTINCT('Sales'[Quarter])
The quarter table has no relationship with the main table.
In the sales table, I have expanded some data to increase the situation in different years.
Create two measures
CQ Sales = var _cq=SELECTEDVALUE('Quarter'[Quarter])
return CALCULATE(SUM('Sales'[Sales]),FILTER('Sales',[Quarter]=_cq))PQ Sales = var _cq=SELECTEDVALUE('Quarter'[Quarter])
var _pq=IF(VALUE(RIGHT(_cq,1))=1,VALUE(LEFT(_cq,4))-1&" Q4",LEFT(_cq,4)&" Q"&VALUE(RIGHT(_cq,1))-1)
RETURN CALCULATE(SUM(Sales[Sales]),FILTER('Sales',[Quarter]=_pq))
Here's the results.
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.