please help with using LEFT function inside the DAX

flora1

New Member
Joined
Nov 27, 2017
Messages
48
I have this =CALCULATE([Sum of Amount], FILTER(DATA, LEFT(VALUES(DATA[Serial]),1)=5)) i am trying to check the condition. but it does not work.

please help me figure out how to use the left function in DAX
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Hi flora1,

I can see two fixes to make here:
  1. You don't need the VALUES function. Since FILTER iterates through the rows of DATA, you can use a direct reference DATA[Serial] to refer to the value on the current row. However, using VALUES gives you a table of all DATA[Serial] values visible in the filter context where the measure is evaluated, which could be multiple values.
  2. You should enclose 5 in quotes since you are comparing it with a text value


One solution is to keep your FILTER function as-is but remove VALUES:
Code:
=CALCULATE ( [Sum of Amount], FILTER ( DATA, LEFT ( DATA[Serial], 1 ) = "5" ) )

You can also write something like this, which I would prefer since it applies a filter only on the DATA[Serial] column rather than iterating/filtering the DATA table:
Code:
=CALCULATE ( [Sum of Amount], KEEPFILTERS ( LEFT ( DATA[Serial], 1 ) = "5" ) )
KEEPFILTERS ensures that the DATA[Serial] filter intersects with any other filters applied which should be in keeping with the intent of your original measure. You could probably omit KEEPFILTERS as long as you aren't applying any other filters that involve DATA[Serial].

Regards,
Owen
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,176
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top