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

combine multiple expression into one CALCULATE function

Dear Community, I want to show AVERAGE and STANDARD DEVIATION, based on below measure I can show AVG, but when i am trying to add STDV, got error, (A function 'STDEV.S' has been used in a True/False expression that is used as a table filter expression. This is not allowed.)
is there a way to show this two with one CALCULATE func,?
or should i separate them? how? 

MeasureStdvY =
IF(
ISINSCOPE('M'[D]),
SUM('M'[Y]),
CALCULATE(
AVERAGE('wash M'[Y]),
STDEV.S('wash M'[Y]),
ALLEXCEPT('S','S'[C],'S'[S], 'S'[L])
)
)
1 ACCEPTED SOLUTION
Icey
Community Support
Community Support

Hi @Anonymous ,

 

You can also try this:

MeasureStdvY =
VAR Avg_ =
    CALCULATE ( AVERAGE ( 'wash M'[Y] ), ALLEXCEPT ( 'S', 'S'[C], 'S'[S], 'S'[L] ) )
VAR Stdev_ =
    CALCULATE ( STDEV.S ( 'wash M'[Y] ), ALLEXCEPT ( 'S', 'S'[C], 'S'[S], 'S'[L] ) )
RETURN
    IF ( ISINSCOPE ( 'M'[D] ), SUM ( 'M'[Y] ), Avg_ & ", " & Stdev_ )

 

 

Best regards

Icey

 

If this post helps, then consider Accepting it as the solution to help other members find it faster.

View solution in original post

4 REPLIES 4
Icey
Community Support
Community Support

Hi @Anonymous ,

 

You can also try this:

MeasureStdvY =
VAR Avg_ =
    CALCULATE ( AVERAGE ( 'wash M'[Y] ), ALLEXCEPT ( 'S', 'S'[C], 'S'[S], 'S'[L] ) )
VAR Stdev_ =
    CALCULATE ( STDEV.S ( 'wash M'[Y] ), ALLEXCEPT ( 'S', 'S'[C], 'S'[S], 'S'[L] ) )
RETURN
    IF ( ISINSCOPE ( 'M'[D] ), SUM ( 'M'[Y] ), Avg_ & ", " & Stdev_ )

 

 

Best regards

Icey

 

If this post helps, then consider Accepting it as the solution to help other members find it faster.

AlB
Super User
Super User

@Helia9235

You can only display one value per column, unless you present them as text with something like:

[MeasureAvgY] &  "-" &  [MeasureStdvY]

Please mark the resolved question when you are finished and consider giving a thumbs up if the posts are useful.

Contact me privately for assistance with any large-scale BI needs, tutoring, etc.

Bless you

SU18_powerbi_badge

AlB
Super User
Super User

Hi @Anonymous 

What do you exactly mean by showing the two? The sum?

If you want the separate results you need two separate measures:

MeasureAvgY =
IF (
    ISINSCOPE ( 'M'[D] ),
    SUM ( 'M'[Y] ),
    CALCULATE (
        AVERAGE ( 'wash M'[Y] ),
        ALLEXCEPT ( 'S', 'S'[C], 'S'[S], 'S'[L] )
    )
)

 

MeasureStdvY =
IF (
    ISINSCOPE ( 'M'[D] ),
    SUM ( 'M'[Y] ),
    CALCULATE (
        STDEV.S ( 'wash M'[Y] ),
        ALLEXCEPT ( 'S', 'S'[C], 'S'[S], 'S'[L] )
    )
)

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

Anonymous
Not applicable

Hi @AlB ,
I want to show both STEV and AVG in one column,Is this possible ? , I do not want to calculate them separately then I will have 2 different measure as you wrote.

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.