Forum Discussion

strikw's avatar
strikw
Helper I
8 years ago
Solved

Formula with conditional

Hello,

I need to filter this formula:
.Media = SUM (Tips [Odd]) / COUNT (Tips [Odd]) //Current formula

 

I need to filter only if it is greater than or equal to 4 (Tips [Odd])

 

I do not know how to make this condition, if anyone can help me.

 

Thank you.

  • Anonymous's avatar
    Anonymous
    8 years ago

    Hi strikw,

     

    Try with this:

    NewMeasure =
    CALCULATE ( [Media]; Tips[Odd] > 4 )

    Or in the same measure:

    Media =
    CALCULATE ( SUM ( Tips[Odd] ) / COUNT ( Tips[Odd] ); Tips[Odd] > 4 )


    Regards.

    Note: If you get a syntax error it's probably because of the semicolons instead of commas, Power BI has the two options to delimit DAX, change semicolons by commas and it should work.

3 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi strikw,

     

    Try with this:

    NewMeasure =
    CALCULATE ( [Media]; Tips[Odd] > 4 )

    Or in the same measure:

    Media =
    CALCULATE ( SUM ( Tips[Odd] ) / COUNT ( Tips[Odd] ); Tips[Odd] > 4 )


    Regards.

    Note: If you get a syntax error it's probably because of the semicolons instead of commas, Power BI has the two options to delimit DAX, change semicolons by commas and it should work.

  • Hi @srikw
    Try this:CALCULATE([Media], filter(Tips [Odd])>=4)
    Alternatively, you can use the same measure and just filter it through visual filter from the filters pane.