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
ph
Helper I
Helper I

function LEFT as measure

Hi,

 

I need to use LEFT() function for each row in table so as a measure in 'row context'. Because my report is based on powerBI dataset, I am unable to use LEFT() as a new column (this operation is unavailable)

 

Any idea how to do it?

 

thx a lot !

3 ACCEPTED SOLUTIONS

Hi @Mariusz 

 

I would like get something like this

 

Batch No.LEFT(Batch No.;3)
123123123
123456123
123789123
987987987
987654987
987321987

 

But I cannot solve it as 'new column', where it is easy to set up

View solution in original post

Mariusz
Community Champion
Community Champion

Hi @ph 

 

Please see the below

Measure = LEFT( MAX( 'Table'[Batch No.] ), 3 )

image.png

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski

 

View solution in original post

Anonymous
Not applicable

[First 3 Chars for Batch No.] =  -- measure
var __oneBatchVisible = HASONEFILTER( T[Batch No.] )
var __chars =
	if (
		__oneBatchVisible,

		var __currentBatch = VALUES( T[Batch No.] )
		var __first3Chars =
			left( __currentBatch, 3 )
		return
			__first3Chars
	)
RETURN
	__chars

Best

D.

View solution in original post

6 REPLIES 6
Mariusz
Community Champion
Community Champion

Hi @ph 

 

Can you provide a data sampe?

 

 

Best Regards,
Mariusz

Please feel free to connect with me.
Mariusz Repczynski

 

Hi @Mariusz 

 

I would like get something like this

 

Batch No.LEFT(Batch No.;3)
123123123
123456123
123789123
987987987
987654987
987321987

 

But I cannot solve it as 'new column', where it is easy to set up

Anonymous
Not applicable

[First 3 Chars for Batch No.] =  -- measure
var __oneBatchVisible = HASONEFILTER( T[Batch No.] )
var __chars =
	if (
		__oneBatchVisible,

		var __currentBatch = VALUES( T[Batch No.] )
		var __first3Chars =
			left( __currentBatch, 3 )
		return
			__first3Chars
	)
RETURN
	__chars

Best

D.

Hi both

 

thank you for your help 🙂 

I accept as solution the first one, because it is easier to understand it, second one is more complicated ..but works fine !!

Mariusz
Community Champion
Community Champion

Hi @ph 

 

Please see the below

Measure = LEFT( MAX( 'Table'[Batch No.] ), 3 )

image.png

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski

 

Anonymous
Not applicable

The measure proposed by Mariusz is not too informative when there is more than 1 Batch No. in scope. The usefulness of it is hampered by the fact that when no Bach No. has been explicitly selected, it'll still return... something. What is this something? Well, it's the first 3 letters from the Batch No. that is the max number out of the visible numbers in the current context. Not sure if this is of any use.

Measures should be defined in such a way that they make sense when they are displayed and when it makes no sense for them to appear, they just return BLANK.

Best
Darek

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!

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.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.