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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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