Forum Discussion
Anonymous
8 years agoNot applicable
Performing calculations on text
I have a column containing a period, which represents a month and year, i.e. 201807 is July of 2018. The data is formatted as a text, and I have a step to create a date from that data: Date.FromTex...
- 8 years ago
Hi Anonymous,
You can convert the text to numeric before caculating, then, change its data type back to Text.
if [Period] = "201807" and ([Sequence] = "1805" or [Sequence] = "1806") then Date.FromText(Text.From((Number.FromText(Text.Range([Period],0,4))-1)) & "-" & Text.Range([Period],4,2) & "-01") else Date.FromText(Text.Range([Period],0,4) & "-" & Text.Range([Period],4,2) & "-01")
Best regards,
Yuliana Gu
v-yulgu-msft
Microsoft Employee
8 years agoHi Anonymous,
You can convert the text to numeric before caculating, then, change its data type back to Text.
if [Period] = "201807" and ([Sequence] = "1805" or [Sequence] = "1806") then Date.FromText(Text.From((Number.FromText(Text.Range([Period],0,4))-1)) & "-" & Text.Range([Period],4,2) & "-01") else Date.FromText(Text.Range([Period],0,4) & "-" & Text.Range([Period],4,2) & "-01")
Best regards,
Yuliana Gu