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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

how to retrieve a scalar value of a text field for a measure

Capture.PNG

I have this kind of a table and I want the average time spent and the conditions are as follows:

     if the category is in first_six or second_six ignore the time spent records which exceeds 4 

     else average of all the records

4 REPLIES 4
v-easonf-msft
Community Support
Community Support

Hi, @Anonymous 

You can try formula as below:

Average time spent =
VAR tab =
    FILTER (
        'Table',
        NOT ( 'Table'[month_category]
            IN { "first_six", "second_six" }
            && 'Table'[time spent] > 4 )
    )
RETURN
    AVERAGEX ( tab, 'Table'[time spent] )

12.png

 

Best Regards,
Community Support Team _ Eason

Tanushree_Kapse
Impactful Individual
Impactful Individual

Hi @Anonymous ,

 

Try this Dax:

 

Average time spent= 
IF(AND(OR(Table[month_category]= "first_six ", Table[month_category]= "second_six "),Table[time_spent] > 4), AVERAGE(Table[time_spent]), blank())

 

 

Mark this as a solution if it answers your question. Kudos are always appreciated.

Thanks

 

 

Check out the data gallery: https://community.powerbi.com/t5/Data-Stories-Gallery/Marvel-Superheroes-Dashboard/td-p/2292663

Anonymous
Not applicable

Since I'm creating a measure "(OR(Table[month_category]= "first_six ", Table[month_category]= "second_six ")" this part should return a scalar value

Hi @Anonymous ,
Try this for a measure:


Average time spent= 

IF(

AND(
OR(SELECTEDVALUE(Table[month_category])= "
first_six ", 
SELECTEDVALUE(Table[month_category])= "second_six "),
SELECTEDVALUE(Table[time_spent]) > 4), AVERAGE(Table[time_spent]),

blank()
)

 

 

Mark this as a solution if it answers your question. Kudos are always appreciated.

Thanks

 

 

Check out the data gallery: https://community.powerbi.com/t5/Data-Stories-Gallery/Marvel-Superheroes-Dashboard/td-p/2292663

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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