Forum Discussion
Help with Quarter data display
Hi All,
I am struggling with a requirement to display quarterly data.
I created a disconnected table to filter quarters as below with index column using
Tried below dax to filter and get last 3 quarters including current quarter data which is working fine.
Flag =
VAR _max =
SELECTEDVALUE ( 'Parameter Table'[Year Quarter] )
VAR _min =
CALCULATE (
MAX ('Parameter Table'[Year Quarter]),
FILTER (
ALL ( 'Parameter Table'),
'Parameter Table'[Index]
= SELECTEDVALUE ( 'Parameter Table'[Index] ) - 3
)
)
VAR _yearQuarter =
(MAX ( Master[Year] ))* 10
+ MAX ( Master[Quarter_Num] )
RETURN
IF ( _yearQuarter <= _max && _yearQuarter >= _min, 1, 0 )
But my requirement is as below:
When I select 2021Q4 it should display previous all years Q4 data including 2021Q4.
Ex:
2021Q4
2020Q4
2019Q4
2018Q4
When I select 2021Q3 it should display 2021Q3 and previous years Q4 data. same logic for Q2 or Q1 as well.
Ex:
2021Q3
2020Q4
2019Q4
2018Q4
Sample date:
| Year | Quarter | Country | Value |
| 2018 | Q4 | America | 10 |
| 2018 | Q4 | Australia | 15 |
| 2018 | Q4 | UK | 20 |
| 2019 | Q1 | America | 25 |
| 2019 | Q2 | Australia | 30 |
| 2019 | Q3 | UK | 35 |
| 2019 | Q4 | America | 40 |
| 2019 | Q1 | America | 45 |
| 2019 | Q2 | Australia | 50 |
| 2019 | Q3 | America | 55 |
| 2019 | Q4 | UK | 60 |
| 2020 | Q1 | America | 65 |
| 2020 | Q2 | America | 70 |
| 2020 | Q3 | Australia | 75 |
| 2020 | Q4 | America | 80 |
| 2021 | Q1 | UK | 85 |
| 2021 | Q2 | America | 90 |
| 2021 | Q3 | America | 95 |
| 2021 | Q4 | Australia | 100 |
| 2022 | Q1 | UK | 105 |
| 2022 | Q1 | America | 110 |
Can someone please suggest.
Thank you
- Anonymous4 years ago
Hi Anonymous ,
Please firstly create a new table to get all distinct Years and Quarters for slicer:
For Slicer = DISTINCT( SELECTCOLUMNS('Table',"Year",[Year],"Quarter",[Quarter]) )Then create a flag measure :
Flag = VAR _seleYear = SELECTEDVALUE ( 'For Slicer'[Year] ) VAR _seleQuar = SELECTEDVALUE ( 'For Slicer'[Quarter] ) RETURN IF ( _seleQuar = "Q4", IF ( MAX ( 'Table'[Year] ) <= _seleYear && MAX ( 'Table'[Quarter] ) = _seleQuar, 1, 0 ), IF ( ( MAX ( 'Table'[Year] ) = _seleYear && MAX ( 'Table'[Quarter] ) = _seleQuar ) || ( MAX ( 'Table'[Year] ) < _seleYear && MAX ( 'Table'[Quarter] ) = "Q4" ), 1, 0 ) )Then apply it to visual-filter pane, set as "is 1":
Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
4 Replies
- AnonymousNot applicable
Hi Anonymous ,
Please firstly create a new table to get all distinct Years and Quarters for slicer:
For Slicer = DISTINCT( SELECTCOLUMNS('Table',"Year",[Year],"Quarter",[Quarter]) )Then create a flag measure :
Flag = VAR _seleYear = SELECTEDVALUE ( 'For Slicer'[Year] ) VAR _seleQuar = SELECTEDVALUE ( 'For Slicer'[Quarter] ) RETURN IF ( _seleQuar = "Q4", IF ( MAX ( 'Table'[Year] ) <= _seleYear && MAX ( 'Table'[Quarter] ) = _seleQuar, 1, 0 ), IF ( ( MAX ( 'Table'[Year] ) = _seleYear && MAX ( 'Table'[Quarter] ) = _seleQuar ) || ( MAX ( 'Table'[Year] ) < _seleYear && MAX ( 'Table'[Quarter] ) = "Q4" ), 1, 0 ) )Then apply it to visual-filter pane, set as "is 1":
Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.- AnonymousNot applicable
Hi Anonymous ,
Thank you so much for the help this is what I expected.
Quick question can we do a percentage difference for the same.
like Quarter over Quarter
- amitchandakSuper User
Anonymous , if you select a value in slicer and then you need more that that, you need an independent table for the slicer
have a table with year , qtr and Year Qtr etc. Use a slicer on that
measure =
var _tab =summarize(allselected(Date), Date[Qtr])
return
calculate(sum(Table[Value]), filter(Table, Table[Qtr] in _tab))
Need of an Independent Table in Power BI: https://youtu.be/lOEW-YUrAbE
Need of an Independent Date Table:https://www.youtube.com/watch?v=44fGGmg9fHI
- AnonymousNot applicable
Hi Amit,
I am new to power bi tried multiple approaches but still struggling to achieve what I want.
I created a new date table as mentioned in your video still no luck.
Could you please guide me with the calculation
when I select any quarter in the selection we need to display previous all years Q4 data including the selected quarter.