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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
iblock
Frequent Visitor

Using Text.Start and Text.End with math operations

I am trying to make this formula work:

Table.AddColumn(#"Renamed Columns", "Term (Months)", each List.Max((Number.FromText(Text.Start([Exp YYYYMM],4))-Number.FromText(Text.Start([Eff YYYYMM],4)))*12+((Number.FromText(Text.End([Exp YYYYMM],2))-Number.FromText(Text.End([Eff YYYYMM],2)))),1))

 

The Eff YYYYMM and Exp YYYYMM columns are of type Integer, so I am not sure if the approach can be simplified.

 

For example, if the Eff YYYYMM = 201507 and Exp YYYYMM = 201707 then Term (Months) should equal 24.

The final result should be in number format.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @iblock ,

 

According to your statement, I think [Eff YYYYMM] and [Exp YYYYMM] columns are of type whole number in Power BI. Here I suggest you to try below code to create custom column.

 

let 
_Mod_Exp = Number.Mod([Exp YYYYMM],100),
_Mod_Eff = Number.Mod([Eff YYYYMM],100)
in
(([Exp YYYYMM]-_Mod_Exp)/100
-
([Eff YYYYMM]-_Mod_Eff)/100)*12
+
_Mod_Exp - _Mod_Eff

 

or

If you need List.Max function, you can try this code.

 

let 
_Mod_Exp = Number.Mod([Exp YYYYMM],100),
_Mod_Eff = Number.Mod([Eff YYYYMM],100)
in
List.Max(
(([Exp YYYYMM]-_Mod_Exp)/100
-
([Eff YYYYMM]-_Mod_Eff)/100)*12
+
_Mod_Exp - _Mod_Eff
,1
)

 

Result is as below.

RicoZhou_0-1673592990919.png

Best Regards,
Rico Zhou

 

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

1 REPLY 1
Anonymous
Not applicable

Hi @iblock ,

 

According to your statement, I think [Eff YYYYMM] and [Exp YYYYMM] columns are of type whole number in Power BI. Here I suggest you to try below code to create custom column.

 

let 
_Mod_Exp = Number.Mod([Exp YYYYMM],100),
_Mod_Eff = Number.Mod([Eff YYYYMM],100)
in
(([Exp YYYYMM]-_Mod_Exp)/100
-
([Eff YYYYMM]-_Mod_Eff)/100)*12
+
_Mod_Exp - _Mod_Eff

 

or

If you need List.Max function, you can try this code.

 

let 
_Mod_Exp = Number.Mod([Exp YYYYMM],100),
_Mod_Eff = Number.Mod([Eff YYYYMM],100)
in
List.Max(
(([Exp YYYYMM]-_Mod_Exp)/100
-
([Eff YYYYMM]-_Mod_Eff)/100)*12
+
_Mod_Exp - _Mod_Eff
,1
)

 

Result is as below.

RicoZhou_0-1673592990919.png

Best Regards,
Rico Zhou

 

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

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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