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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Luis_Caston
Helper III
Helper III

Calculate filtering text column by range

Hi guys!

 

I'm hesitanting:

  • I've a column [CodigoFinca] with this text values: 01,02,03,04,05,06,07,08,09,10,MIXED, ALONE.

 

I want to calculate in a range from 01 to 07 but is text not number.
I've created this formula and it works perfectly:

  • SUMX(VALUES(Cultivo), CALCULATE( [Hectáreas Final],
    USERELATIONSHIP(CabeceraCampo[FechaPlantacion], Calendario[Fecha]),
    FILTER(ALL(Calendario), Calendario[Fecha] <= MAX(Calendario[Fecha])), Cultivo[CodigoFinca] IN {"01","02","03", "04","05","06", "07"}))


Do you think that on this way is the best option?

  • Cultivo[CodigoFinca] IN {"01","02","03", "04","05","06", "07"}

Is there another way as for example:

  • Cultivo[CodigoFinca] BETWEEN {"01","08"}

Or whatever.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @Luis_Caston ,

 

You can modify it to the following  measure:

Test1_Measure =
var _text=
ISERROR(VALUE(MAX('Cultivo'[CodigoFinca])))
var _if=
IF(
    _text=FALSE(),MAX([CodigoFinca]),BLANK())
return
VALUE(_if)
Test2_Measure =
SUMX(
    FILTER(ALL('Cultivo'),
    [Test1_Measure]<=8&&[Test1_Measure]<>BLANK()),[Hectáreas Final])

vyangliumsft_0-1724397487817.png

Best Regards,

Liu Yang

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

4 REPLIES 4
Anonymous
Not applicable

Hi  @Luis_Caston ,

 

You can modify it to the following  measure:

Test1_Measure =
var _text=
ISERROR(VALUE(MAX('Cultivo'[CodigoFinca])))
var _if=
IF(
    _text=FALSE(),MAX([CodigoFinca]),BLANK())
return
VALUE(_if)
Test2_Measure =
SUMX(
    FILTER(ALL('Cultivo'),
    [Test1_Measure]<=8&&[Test1_Measure]<>BLANK()),[Hectáreas Final])

vyangliumsft_0-1724397487817.png

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you @Anonymous!!
Pretty amazing!
I've adapted the formula following your criteria and works perfectly.

"[HA codigo finca]" is yours "Test1_Meausre]". 

SUMX(VALUES(Cultivo), CALCULATE( [Hectáreas Final], USERELATIONSHIP(CabeceraCampo[FechaPlantacion], Calendario[Fecha]), FILTER(ALL(Calendario), Calendario[Fecha] <= MAX(Calendario[Fecha])),
FILTER(ALL(Cultivo[CodigoFinca]), [HA Codigo finca]<=7&&[HA Codigo finca]<>BLANK())))

Thank you so much, universal and pretty simple.

 

Anonymous
Not applicable

Hi  @Luis_Caston ,

I created some data:

vyangliumsft_0-1724376445906.png

You can use ISERROR() and VALUE() to determine TRUE/FALSE.

Create measure.

Measure =
SUMX(
    FILTER(ALL('Cultivo'),
    ISERROR(
    VALUE('Cultivo'[CodigoFinca]))=FALSE()),[Hectáreas Final])

Result:

vyangliumsft_1-1724376445909.png

You can try placing the following filter condition in your formula:

ISERROR(VALUE('Cultivo'[CodigoFinca]))=FALSE())

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Hi!!
First of all, thank you for your support!
Good idea 💪
In this case would be perfect if I would want to sum all the range except "text" from "01" to "10".
But if I only want to sum from "01" to "08"?

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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