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
DionTN
Helper II
Helper II

Use calculation for multiple rows

Im trying to get a mean for every first measurement. So i have a function which calculates all the first measurements. I want to use this to get the mean of all first measurements.

 

 

GemiddeldeLichaamssamenstellingEerste = var selectie = SELECTEDVALUE(company[Name])  var EersteWaarde = CALCULATE(MIN(usermeasurements[AppointmentId]),FIRSTDATE(usermeasurements[OnderzoekVerichtOp])) var LS = CALCULATE(AVERAGE(usermeasurements[BodyCompositionOverall]),FILTER(usermeasurements,usermeasurements[users.company.Name] = selectie), (usermeasurements[appointments.AppointmentNumber]= EersteWaarde)) return COALESCE(LS/10,0)   

 

 

When i select just 1 name it is working, but when i select a couple of names it fails.

 

DionTN_0-1660049577845.png

 

1 ACCEPTED SOLUTION

Im sorry, the mistake was probably in the defination of FirstValue.

 

DionTN_0-1660054843112.png

It reads only the lowest firstValue. So in this example, only richard will get a score cause of he has appointmentID 1

FirstValue = var selectie = SELECTEDVALUE(company[Name]) var EersteWaarde = CALCULATE(MIN(usermeasurements[AppointmentId]),FIRSTDATE(usermeasurements[OnderzoekVerichtOp]), FILTER(usermeasurements,usermeasurements[users.company.Name] = selectie)) return EersteWaarde

 

View solution in original post

2 REPLIES 2
johnt75
Super User
Super User

SELECTEDVALUE only work when there is a single value, otherwise it will return blank. Try

GemiddeldeLichaamssamenstellingEerste =
VAR selectie =
    ADDCOLUMNS (
        VALUES ( company[Name] ),
        "EersteWaarde",
            CALCULATE (
                MIN ( usermeasurements[AppointmentId] ),
                FIRSTDATE ( usermeasurements[OnderzoekVerichtOp] )
            )
    )
VAR LS =
    CALCULATE (
        AVERAGE ( usermeasurements[BodyCompositionOverall] ),
        TREATAS (
            selectie,
            usermeasurements[users.company.Name],
            usermeasurements[appointments.AppointmentNumber]
        )
    )
RETURN
    COALESCE ( LS / 10, 0 )

Im sorry, the mistake was probably in the defination of FirstValue.

 

DionTN_0-1660054843112.png

It reads only the lowest firstValue. So in this example, only richard will get a score cause of he has appointmentID 1

FirstValue = var selectie = SELECTEDVALUE(company[Name]) var EersteWaarde = CALCULATE(MIN(usermeasurements[AppointmentId]),FIRSTDATE(usermeasurements[OnderzoekVerichtOp]), FILTER(usermeasurements,usermeasurements[users.company.Name] = selectie)) return EersteWaarde

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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