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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
kormosb
Helper III
Helper III

t-1 quarter DAX - missing values

Hi,

 

I am facing an issue I would like to get help with.

 

I woud like to calculate the value of the previous quarter with the following DAX:

 

 

Value T-1 = CALCULATE('Value'[Value T],DATEADD('Quarter'[Last day of Quarter],-1,QUARTER))​

 

 

As you can see in the picture there are some missing values for the previous quarters, but I don't know why.

issue.JPG

 

Can you help me find the problem?

 

Please find attached the pbix and excel files.

Files 

 

Kind regards,

Benjamin

 

1 ACCEPTED SOLUTION
v-alq-msft
Community Support
Community Support

Hi, @kormosb 

 

I'd like to suggest you create a calculated column and a measure as below.

Calculated column:

YearQuarter = [Year]*10+[Q]

Measure:

LastYearQuarter Value = 
var _yearquarter = SELECTEDVALUE('Quarter'[YearQuarter])
var _lastyearquarter = 
CALCULATE(
        MAX('Quarter'[YearQuarter]),
        FILTER(
            ALL('Quarter'),
            'Quarter'[YearQuarter]<_yearquarter
        )
)
return
IF(
    NOT(ISBLANK(_lastyearquarter)),
    CALCULATE(
        SUM('Value'[Value]),
        FILTER(
            ALL('Quarter'),
            'Quarter'[YearQuarter] = _lastyearquarter
        )
    )
)

 

Result:

b1.PNG

 

Best Regards

Allan

 

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

View solution in original post

2 REPLIES 2
v-alq-msft
Community Support
Community Support

Hi, @kormosb 

 

I'd like to suggest you create a calculated column and a measure as below.

Calculated column:

YearQuarter = [Year]*10+[Q]

Measure:

LastYearQuarter Value = 
var _yearquarter = SELECTEDVALUE('Quarter'[YearQuarter])
var _lastyearquarter = 
CALCULATE(
        MAX('Quarter'[YearQuarter]),
        FILTER(
            ALL('Quarter'),
            'Quarter'[YearQuarter]<_yearquarter
        )
)
return
IF(
    NOT(ISBLANK(_lastyearquarter)),
    CALCULATE(
        SUM('Value'[Value]),
        FILTER(
            ALL('Quarter'),
            'Quarter'[YearQuarter] = _lastyearquarter
        )
    )
)

 

Result:

b1.PNG

 

Best Regards

Allan

 

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

amitchandak
Super User
Super User

@kormosb , With date table you can get Last qtr like

 

QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(('Date'[Date])))

Last QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(dateadd('Date'[Date],-1,QUARTER)))

Last complete QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD( ENDOFQUARTER(dateadd('Date'[Date],-1,QUARTER))))
Last to last QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(dateadd('Date'[Date],-2,QUARTER)))
Next QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(dateadd('Date'[Date],1,QUARTER)))
Last year same QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(dateadd('Date'[Date],-1,Year)))
Last year same QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(ENDOFQUARTER(dateadd('Date'[Date],-1,Year))))
trailing QTR = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,QUARTER))

 

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

See if my webinar on Time Intelligence can help: https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-Y...

In case you do not have date then you can use Qtr Rank to that

Same what I done for week -https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-La...
Appreciate your Kudos.

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

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.