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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

last year december balance and end of previous quarter balance

Dear all

I had a measure to calculate balance at the end of year(dec) and balance at the end of each quarter and month as below which is working fine

Selected ARBalLegal = SWITCH([SelectedPeriod],
"Month", CALCULATE(SUM(Aging_table[TotalAmount]),Aging_table[ClassLegal]="L", Aging_table[TotalAmount]>0,),
"Quarter", CALCULATE(SUM(Aging_table[TotalAmount]),Aging_table[ClassLegal]="L",Aging_table[TotalAmount]>0, ,filter(DimDate, DimDate[Date]=DimDate[FirstDay EndOfQtr])),
"Year", CALCULATE(SUM(Aging_table[TotalAmount]),Aging_table[ClassLegal]="L",Aging_table[TotalAmount]>0, filter(DimDate, DimDate[Date]=DimDate[FirstDay EndOfYear])),
CALCULATE(SUM(Aging_table[TotalAmount]),Aging_table[ClassLegal]="L", Aging_table[TotalAmount]>0,))
Based on above query Output is 
 SamarK_1-1617172062534.png
FirstDay EndOfQtr = STARTOFMONTH(ENDOFQUARTER(DimDate[Date])) used in above query
FirstDay EndOfYear = STARTOFMONTH(ENDOFYEAR(DimDate[Date])) used in above query
 

Date Table

SamarK_0-1617170923351.png

I want to calculate end of last year bal and end of previous quarter balances as below

When Year

SamarK_2-1617172112938.png

when Qtr

SamarK_3-1617172401428.png

 

Please help me to write measure.

 

Regards

Samar

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , You have a few functions to give end of qtr/year balance - closingbalancemonth, closingbalancequarter, closingbalanceyear

 

Last period closing balance - openingbalancemonth,openingbalancequarter, openingbalanceyear

 

refer my video for that -

https://www.youtube.com/watch?v=yPQ9UV37LOU

https://www.youtube.com/watch?v=6lzYOXI5wfo

 

 

Or use time intelligence for complete data

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

 

MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))

 

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 :radacad sqlbi My Video Series Appreciate your Kudos.

 

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"12/31"))
Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-1,Year),"12/31"))

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@Anonymous , You have a few functions to give end of qtr/year balance - closingbalancemonth, closingbalancequarter, closingbalanceyear

 

Last period closing balance - openingbalancemonth,openingbalancequarter, openingbalanceyear

 

refer my video for that -

https://www.youtube.com/watch?v=yPQ9UV37LOU

https://www.youtube.com/watch?v=6lzYOXI5wfo

 

 

Or use time intelligence for complete data

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

 

MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))

 

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 :radacad sqlbi My Video Series Appreciate your Kudos.

 

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"12/31"))
Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-1,Year),"12/31"))

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.