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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Creating a measure with filters

I am creating a card visual that has to display the gestational age based on the type of program,


>If it is prenatal it should display the appropriate gestational age on patient level and on population level it should display the average of the gestational age


>If the  program is not prenatal then the card should display nothing


Using my current logic , I am able to get the minimum gestational age but not the average.This the logic that I am using for the card currently,

Gestational Age-Filter = IF(Overview[Gestational Age - Copy]<>BLANK(),INT((Overview[Gestational Age - Copy])/7)&"W"& ROUND(MOD((Overview[Gestational Age - Copy]),7),0)&"D"),and this one displays the minimum gestational age,I can't use an average formula on top of this calculated column,since this is a string.
 
I also tried using a measure,
 
Gestational_age = calculate((INT(AVERAGE(Overview[Gestational Age - Copy])/7)&"W "& ROUND(MOD(AVERAGE(Overview[Gestational Age - Copy]),7),0)&"D"))
Now when I use this I am able to see W D being displayed on the card,when the gestational age is not available.
 
How can I handle this?
 
1 ACCEPTED SOLUTION
v-lid-msft
Community Support
Community Support

Hi @Anonymous ,

 

We can try to use the following measure to meet your requirement:

 

Gestational_age =
IF (
    CALCULATE (
        COUNTROWS ( Overview ),
        Overview[Gestational Age - Copy] <> BLANK ()
    ) = 0,
    BLANK (),
    CALCULATE (
        (
            INT ( AVERAGE ( Overview[Gestational Age - Copy] ) / 7 ) & "W "
                & ROUND ( MOD ( AVERAGE ( Overview[Gestational Age - Copy] ), 7 ), 0 ) & "D"
        )
    )
)

 

 

If it doesn't meet your requirement, kindly share your sample data and expected result to me if you don't have any Confidential Information. Please upload your files to One Drive and share the link here.


Best regards,

 

Community Support Team _ Dong Li
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

2 REPLIES 2
v-lid-msft
Community Support
Community Support

Hi @Anonymous ,

 

We can try to use the following measure to meet your requirement:

 

Gestational_age =
IF (
    CALCULATE (
        COUNTROWS ( Overview ),
        Overview[Gestational Age - Copy] <> BLANK ()
    ) = 0,
    BLANK (),
    CALCULATE (
        (
            INT ( AVERAGE ( Overview[Gestational Age - Copy] ) / 7 ) & "W "
                & ROUND ( MOD ( AVERAGE ( Overview[Gestational Age - Copy] ), 7 ), 0 ) & "D"
        )
    )
)

 

 

If it doesn't meet your requirement, kindly share your sample data and expected result to me if you don't have any Confidential Information. Please upload your files to One Drive and share the link here.


Best regards,

 

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Thanks a lot ,it worked well.Can you please explain how this works.I want to know more so that I can apply this with other problems as well.

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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