Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
Anonymous
Not applicable

How to calculate Dynamic quarters

Hello guys I have to calculate the dynamics QUATERS  I mean now this is Sept month means Q2  so  want to show the values of Q2 and Q1 also in the next month the quarter  will change then it will show the value of Q1,Q2 and Q3 ..and then when the quarter 4 will start in it will show the values of Q1 Q2,Q3 and Q4 and then when  new year start the then it show show the value of current quarter Q1 how to do this plz help

1 ACCEPTED SOLUTION

Hi @Anonymous 

try this, then put the measure into visual level filter

filterMeasure = 
VAR _currentMonth = 7 //replace it with month(today())
VAR _currentYear = 2022//replace it with year(today())
VAR _quarter =
    DIVIDE ( _currentMonth, 3 )
VAR _day =
    _quarter - QUOTIENT ( _currentMonth, 3 )
VAR _startDate =
    IF (
        _currentMonth < 4,
        DATE ( _currentYear - 1, 1, 1 ),
        DATE ( _currentYear, 1, 1 )
    )
VAR _endDate =
    SWITCH (
        TRUE (),
        _currentMonth < 4, DATE ( _currentYear - 1, 12, 31 ),
        _day <> 0,
            DATE ( _currentYear, INT ( _quarter ) * 3 + 1, 1 ),
        _day = 0,
            DATE ( _currentYear, ( _quarter - 1 ) * 3 + 1, 1 )
    )
RETURN
    IF(MIN('value'[date])<_endDate&&MIN('value'[date])>=_startDate,1,0)

2021/10

vxiaotang_0-1633426345634.png

2022/1

vxiaotang_2-1633426401116.png

2022/7

vxiaotang_3-1633426491881.png

Best Regards,

Community Support Team _Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
v-xiaotang
Community Support
Community Support

Hi @Anonymous 

you can refer to the posts,

https://community.powerbi.com/t5/Desktop/Dynamically-display-last-8-quarters/td-p/394240

https://community.powerbi.com/t5/Desktop/Display-last-4-quarters-sum-dynamically/td-p/1045885

https://community.powerbi.com/t5/Desktop/Current-Quarter-and-last-quarter-calculation/td-p/703345

 

if you need more help, please @ me

 

Best Regards,

Community Support Team _Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Thanks for your Reply

I have to show the quaters in columns like Q1 ,Q2,Q3,Q4 now it's oct month means it comes in Q3 so my matrix will show  Q1 column ,Q2 column & Q3  column  and when Jan month will Start matrix will show Q1,Q2,Q3 Q4 ...and after that when new FY will Start i have to show the only Q1 of this year.

Hi @Anonymous 

try this, then put the measure into visual level filter

filterMeasure = 
VAR _currentMonth = 7 //replace it with month(today())
VAR _currentYear = 2022//replace it with year(today())
VAR _quarter =
    DIVIDE ( _currentMonth, 3 )
VAR _day =
    _quarter - QUOTIENT ( _currentMonth, 3 )
VAR _startDate =
    IF (
        _currentMonth < 4,
        DATE ( _currentYear - 1, 1, 1 ),
        DATE ( _currentYear, 1, 1 )
    )
VAR _endDate =
    SWITCH (
        TRUE (),
        _currentMonth < 4, DATE ( _currentYear - 1, 12, 31 ),
        _day <> 0,
            DATE ( _currentYear, INT ( _quarter ) * 3 + 1, 1 ),
        _day = 0,
            DATE ( _currentYear, ( _quarter - 1 ) * 3 + 1, 1 )
    )
RETURN
    IF(MIN('value'[date])<_endDate&&MIN('value'[date])>=_startDate,1,0)

2021/10

vxiaotang_0-1633426345634.png

2022/1

vxiaotang_2-1633426401116.png

2022/7

vxiaotang_3-1633426491881.png

Best Regards,

Community Support Team _Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@Anonymous , I think you are having a year starting in April and you need YTD

 

With help from date table and time intelligence. Create Qtr column in calendar

 

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"3/31"))

 

 

refer if needed

Creating Financial Calendar - From Any Month
https://community.powerbi.com/t5/Community-Blog/Creating-Financial-Calendar-Decoding-Date-and-Calendar-1-5-Power/ba-p/1187441

 


Power BI — Year on Year with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-ytd-questions-time-intelligence-1-5-e3174b39f38a
https://www.youtube.com/watch?v=km41KfM_0uA

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

I have to show the quaters in columns like Q1 ,Q2,Q3,Q4 now it's Sept month means it comes in Q2 so my matrix will show only Q1 column and Q2 column in the next month Oct the Q3 will start then my matrix show the Q1,Q2,Q3 columns

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.