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
naoyixue1
Post Patron
Post Patron

Calculate Coefficient as column not measure

Hey all,

 

Since I want to add the attributes of coefficient of variance at SKU level, I want to calculate that as column not measure. (see below examples) 

Coefficient of variance = standard deviation /  average 

 

Given that, i should calculate

    1: the weekly average value based on how many weeks total for each item.

    2: the standard deviation of value at SKU level

    3: standard deviation / average 

 

Do you know how to calculate that in the column? Since I finally want to pull some graph based on the attributes of coefficient of variance. So that one have to be calculated not the measure. Any thoughts? Thanks!

 

naoyixue1_0-1670894409090.png

 

1 ACCEPTED SOLUTION

Hi @naoyixue1 ,

Please check if this is the output you want?

Column = 
VAR _sku_total = CALCULATE(SUM('Table'[Value]),FILTER(ALL('Table'),'Table'[SKU]=EARLIER('Table'[SKU])))
VAR _week_count = CALCULATE(DISTINCTCOUNT('Table'[Week]),FILTER(ALL('Table'),'Table'[SKU]=EARLIER('Table'[SKU])))
VAR _avg = DIVIDE(_sku_total,_week_count)
VAR _stdevx = STDEVX.S(FILTER(ALL('Table'),'Table'[SKU]=EARLIER('Table'[SKU])),'Table'[Value])
VAR _result = DIVIDE(_stdevx,_avg)
RETURN
_result

vcgaomsft_0-1671008885489.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

View solution in original post

3 REPLIES 3
naoyixue1
Post Patron
Post Patron

@v-cgao-msft Thanks, Gao! It works for me. 

naoyixue1
Post Patron
Post Patron

Any thoughts? 

Hi @naoyixue1 ,

Please check if this is the output you want?

Column = 
VAR _sku_total = CALCULATE(SUM('Table'[Value]),FILTER(ALL('Table'),'Table'[SKU]=EARLIER('Table'[SKU])))
VAR _week_count = CALCULATE(DISTINCTCOUNT('Table'[Week]),FILTER(ALL('Table'),'Table'[SKU]=EARLIER('Table'[SKU])))
VAR _avg = DIVIDE(_sku_total,_week_count)
VAR _stdevx = STDEVX.S(FILTER(ALL('Table'),'Table'[SKU]=EARLIER('Table'[SKU])),'Table'[Value])
VAR _result = DIVIDE(_stdevx,_avg)
RETURN
_result

vcgaomsft_0-1671008885489.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

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.