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
Nazram
New Member

Frequency and normal distribution calculation

First of all thank you all for your time.

 

I am sure that this question is pretty basic and it have been answered before but I couldn't find it at the forums. So sorry for repeating myself if that it is the case.

 

I have this array of data (as an example):

 Overlord.PNG

 

 

 

 

 

 

 

 

 

 

 

 

I want, directly in PowerBI, to calculate the frequency of the number of "Underlings" according to a bin that I specify.

Additionally, I will also want to calculate the normal distribution of this "Underlings" data (maybe this example does not follow the distribution but the real data does). At this moment I can do this easy at excel and then import another table. The final result calculated in excel look like these:

 

 Frequency.PNG

In case anyone wonder I want to these directly in PowerBI in order to be able to navigate throw the different filters and "families" associated to the "Overlords" (not included at this example). So the frequency also filters when I change "families" and are not a static image of the whole data.

1 ACCEPTED SOLUTION
v-danhe-msft
Employee
Employee

Hi @Nazram,

Based on my test, you can refer to below steps:

1.I have entered some sample data to test for your problems. Table1 is the data I entered below in the picture. Table2 covered the data of [bin].

1.PNG             2.PNG

 

2.Create a calculated column to calculate your frequency in 'Table2'. Create a table visual to show your [bin] and [Frequency].

Frequency = IF(ISBLANK(COUNTROWS(FILTER(Table1,VALUE(Table1[Underlings])=VALUE(Table2[Bin])))),0,COUNTROWS(FILTER(Table1,VALUE(Table1[Underlings])=VALUE(Table2[Bin]))))

3.PNG

6.PNG

3.Create four new measures to calculate the average, the Variance and the Variance range.

Mean = AVERAGE(Table1[Underlings])

Standard DEV = STDEV.S(Table1[Underlings])

X-3a = [Mean]-3*[Standard DEV]

X+3a = [Mean]+3*[Standard DEV]

 

4.Create a new table to calculate the normal distribution.

‘Normal distribution’ =

var minvalue=FLOOR([X-3a],1)

var maxvalue=CEILING([X+3a],1)

return SELECTCOLUMNS(CALENDAR(minvalue,maxvalue),"x",INT([Date]))

 

5.Create a calculated column to calculate the normal distribution value, and a new measure to calculate the ration.

z = ('Normal distribution'[x]-[Mean]/[Standard DEV])

f(x) =  EXP((VALUES('Normal distribution'[x])-[Mean])^2/(2*[Standard DEV]^2)*-1)/(SQRT(2*PI())*[Standard DEV])

4.PNG

 

6.Create a Table visual to add the [x] and the [z] fields. And modify the "Total" off. Then add the [f(x)] field.

7.PNG

Now you can get your "Frequency" and "Nominal distribution".

8.PNG

You can also download the PBIX file to have a view.

https://www.dropbox.com/s/vs2uu8grdb038r6/Frequency%20and%20normal%20distribution%20calculation.pbix...

 

Regards,

Daniel He

Community Support Team _ Daniel He
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-danhe-msft
Employee
Employee

Hi @Nazram,

Based on my test, you can refer to below steps:

1.I have entered some sample data to test for your problems. Table1 is the data I entered below in the picture. Table2 covered the data of [bin].

1.PNG             2.PNG

 

2.Create a calculated column to calculate your frequency in 'Table2'. Create a table visual to show your [bin] and [Frequency].

Frequency = IF(ISBLANK(COUNTROWS(FILTER(Table1,VALUE(Table1[Underlings])=VALUE(Table2[Bin])))),0,COUNTROWS(FILTER(Table1,VALUE(Table1[Underlings])=VALUE(Table2[Bin]))))

3.PNG

6.PNG

3.Create four new measures to calculate the average, the Variance and the Variance range.

Mean = AVERAGE(Table1[Underlings])

Standard DEV = STDEV.S(Table1[Underlings])

X-3a = [Mean]-3*[Standard DEV]

X+3a = [Mean]+3*[Standard DEV]

 

4.Create a new table to calculate the normal distribution.

‘Normal distribution’ =

var minvalue=FLOOR([X-3a],1)

var maxvalue=CEILING([X+3a],1)

return SELECTCOLUMNS(CALENDAR(minvalue,maxvalue),"x",INT([Date]))

 

5.Create a calculated column to calculate the normal distribution value, and a new measure to calculate the ration.

z = ('Normal distribution'[x]-[Mean]/[Standard DEV])

f(x) =  EXP((VALUES('Normal distribution'[x])-[Mean])^2/(2*[Standard DEV]^2)*-1)/(SQRT(2*PI())*[Standard DEV])

4.PNG

 

6.Create a Table visual to add the [x] and the [z] fields. And modify the "Total" off. Then add the [f(x)] field.

7.PNG

Now you can get your "Frequency" and "Nominal distribution".

8.PNG

You can also download the PBIX file to have a view.

https://www.dropbox.com/s/vs2uu8grdb038r6/Frequency%20and%20normal%20distribution%20calculation.pbix...

 

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks @v-danhe-msft,

This exactly what is was looking for. And at the same time you teach me a lot of things of PowerBI. I am relatively new and programming was never my strong point. Thanks for your time and effort.

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.