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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

MTD calculated column

Hi,

 

I have source data amounts presented in year-to-date (IBM Cognos) and are trying to create a calculated column in the fact table that is presenting the month-to-date value. Example below:

 

allebergh_0-1639752175115.png

Although I managed to calulate this using below DAX formula have I not found a way of calculating a month-to-date value when no year-to-date value has been reported in one period. Example in the data set above are revenues coded on cost center (DIM3) "4112" in the beginning of the year although changed to "4113" in June. The correct MTD value for June should have been -210 (=0-210) on DIM3 "4112" and +290 (=290-0) on DIM3 "4113" (i.e. together 40). However since Im missing a row with zero YTD amount for DIM4112 in June are my formula not calculating that row and end up showing +290 in total for the month.

 

Any guidance on how to solve this challenge is highly appreciated!

Thanks

Alexander

 

AmountMTD =
VAR _Dim1 = 'DW V_FactControllerLedgerExpanded'[DIM1]
VAR _Dim2 = 'DW V_FactControllerLedgerExpanded'[DIM2]
VAR _Dim3 = 'DW V_FactControllerLedgerExpanded'[DIM3]
VAR _Acc = 'DW V_FactControllerLedgerExpanded'[Account]

VAR _PrevPeriod = DATEADD('DW V_FactControllerLedgerExpanded'[Date], -1, MONTH)

VAR _PrevValue = LOOKUPVALUE('DW V_FactControllerLedgerExpanded'[AmountYTD],
'DW V_FactControllerLedgerExpanded'[DIM1], _Dim1,
'DW V_FactControllerLedgerExpanded'[DIM2], _Dim2,
'DW V_FactControllerLedgerExpanded'[DIM3], _Dim3,
'DW V_FactControllerLedgerExpanded'[Account], _Acc,
'DW V_FactControllerLedgerExpanded'[Date], _PrevPeriod)

VAR _MTDvalue = 'DW V_FactControllerLedgerExpanded'[AmountYTD] - _PrevValue

RETURN
IF(MONTH('DW V_FactControllerLedgerExpanded'[Date]) = 1, 'DW V_FactControllerLedgerExpanded'[AmountYTD], _MTDvalue)

2 REPLIES 2
v-xiaotang
Community Support
Community Support

Hi @Anonymous 

You could create create an independent MTD column, please provide more details, then we can readjust your columns according to your needs.

(1) a sample file, you can replace raw data with bogus data to protect your privacy.

(2) or provide some sample data that fully covers your issue/question

(3) give your expected result based on the sample you provide

(Kindly note: Please ensure the data in sample is concise and representative)

Thanks.

 

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 , A new column

 

New column =
[YTD] = maxx(filter(Table, [Date] = earlier([Date])-1 && [Account] = earlier([Account] )
&& [DIM1] = earlier([DIM1] )
&& [DIM2] = earlier([DIM2] ) ),[YTD])

 

 

Add and remove equal joins as per need

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
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.