Home » DAX » ISAFTER DAX Function

ISAFTER DAX Function

ISAFTER function With Measure

The ISAFTER DAX function is used to return a record after the start position specified in condition, and returns the result as a Boolean.

Based on the sort order, the first parameter is compared with the second parameter. If the sort order is ascending, the comparison to be done is first parameter greater than the second parameter.

If the sort order is descending, the comparison to be done is second parameter less than the first parameter.

Syntax

ISAFTER(<scalar_expression>, <scalar_expression>, sort_order , <scalar_expression>, <scalar_expression>, sort_order…)

Parameters

scalar expression – Any expression that returns a scalar value like a column reference or integer or string value. Typically the first parameter is a column reference and the second parameter is a scalar value.

sort order– (optional) The order in which the column is sorted. Can be ascending (ASC) or descending (DEC). By default the sort order is ascending.

Sample data set for example

ID Product Sales
1 A 100
2 B 200
3 C 50
4 D 40
5 E 100
6 F 100
7 A 50
8 B 100




Let’s Get Started

Create a New column and write below DAX formula

Flg = ISAFTER(TempData[Product], "B", ASC)

This formula will return True for all records after B Product.  Here, Product order is ASC.

ISAFTER DAX Power BI

ISAFTER DAX Power BI

Now change the Product order DESC and see the result- It will return True for before B products.

Flg = ISAFTER(TempData[Product], "B", DESC)
ISAFTER DAX with DESC Order

ISAFTER DAX with DESC Order



ISAFTER DAX with Measure

Create a measure with below DAX formula-

ISAFTER DAX =
CALCULATE (
    SUM ( TempData[Sales] ),
    FILTER ( TempData, ISAFTER ( TempData[Product], "B", ASC))
)

See result below, only return Product after B.

ISAFTER function With Measure

ISAFTER function With Measure

Hope you enjoyed the post, you can refer Other DAX functions: DAX functions

Leave a Reply