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
Jack-B-Quick
Frequent Visitor

Inverse Cumulative Frequency

New to BI and just getting my feet wet.

 

I have the following summary table below based on some backgroud data ('SampleLicCnts' table). The Frequency column was simple of course, just set the value to 'count' vs 'sum'. I created the Bin column so I could use it to calculate the Cummulative Frequecy. Respective formulas for Bin and Cumulative Frequency here...

 

Bin = FLOOR(DIVIDE('SampleLicCnts'[LicCnt],1),1)
Cumulative Frequency = CALCULATE(COUNT(SampleLicCnts[LicCnt])
,FILTER(ALL(SampleLicCnts),SampleLicCnts[BIN_NUMBER]<=MAX(SampleLicCnts[BIN_NUMBER])))

I'm struggling to calculate the Inverse Cumulative Frequency (red text) as show here...

 

LicensesBinFrequencyCumulative FrequencyInverse Cumulative Frequency
112715271590980
221774448988265
331083557283776
44565613778204
55249638672067
66100648665681
7744653059195
8827655752665
9916657346108
10108658139535
11116658732954
12121658826367
13133659119779
14142659313188
1515265956595

 

I tried to reverse to logic of the Cumulative Frequecy by changing the <=MAX to >=MIN but that doesn't produce the correct results. I also referenced this "Inverse Sum" topic but it's not quite the same problem.

 

Any ideas on how to calculate the Inverse Cumulative Frequency? BTW...Utimately I'm after the Inverse Cumulative Relative Frequency, but to get there I first need the Inverse Cumulative Frequency.

 

Thanks in advance!

1 ACCEPTED SOLUTION

I see what you mean about the data shifting.  For this solution, I'm assuming that your Lic value can be sorted in your data and isn't just a random key.  If so, you'll likely need to create the Bin column again, just to keep it sortable.

 

First, I changed the Cumulative Frequency measure to this expression:

Cumulative count = if(HASONEVALUE(Data[LicCnt]),COUNTAX(FILTER(ALL(Data),Data[LicCnt]<=SELECTEDVALUE(Data[LicCnt])),[Count]),BLANK())

Then I set the Inverse Cumulative Frequency measure to this:

Measure1 = SUMX(FILTER(SUMMARIZE(ALL(Data),Data[LicCnt],"Cumulative Count",[Cumulative count]),[LicCnt]>=SELECTEDVALUE(Data[LicCnt])),[Cumulative count])

What this is doing is creating a virtual table where it appends the Cumulative Count to the LicCnt, and then rolls that up to a single table that looks like this:

snipo.PNG

Then it sums the values from this virtual table where the LicCnt is greater than the current value.  This keeps the count when things are re-ordered via sorting, but relies on you being able to sort by LicCnt.

View solution in original post

8 REPLIES 8
Ashish_Mathur
Super User
Super User

Hi,

Could you share the raw data (in a format that can be pasted in an MS Excel file)?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

The basis for the data is based off a very simple text (LicCnt.txt) file that looks like the data below (first 50 rows of data copy\pasted). The problem doesn't change, but there are 6595 rows in total with varing values from 1-15 (Frequency of each value presented above). I'd attach the file but I don't see an option to do so.

 

Also...A slightly ambigious error on my part in the original post. I don't actually have a separate "Summary" table (only the original imported "LicCnt" table). I added the Bin column to the table (per the formula above). I then created a Visual and added LicCnt (change from Sum to Count) to get the Frequency column. Then I created a measure to get the Cumulative Frequency (again per the formula above).

 

Thanks!

 

LicCnt
1
1
1
1
1
1
1
1
3
3
3
4
2
2
4
2
1
1
1
1
2
1
1
3
5
2
2
1
2
2
3
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
4
4
5

Hi,

Is this the result you are expecting?  You may download my PBI file from here.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

The results you show (and in your file) are close, but not quite what I want, and they change based on the way the data is sorted (this is not desired). Based on the first 50 rows of data pasted above, here are the results I expect. This seems to be overly difficult in BI as compared to very simple formulas and "fills" in Excel.

 

LicFrequencyCumulative FrequencyInverse Cumulative FrequencyInverse Cumulative Relative Frequency
115151961.0000
224391810.9235
35441420.7245
4448980.5000
5250500.2551

 

I'm looking at your functions trying to figure out exactly what they are doing, but I'm not yet familiar with RANKX and some of the other logic you used.

 

HotChilli: I thank you for your help as well, but your formula doesn't return the proper values for the Inverse Cumulatave Frequency either. And yes, I now realize adding the Bin column was not necessary.

 

Thanks!

Hi,

I am not clear about your requirement.  Are you saying that LicCnt should always be in ascending order.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

I see what you mean about the data shifting.  For this solution, I'm assuming that your Lic value can be sorted in your data and isn't just a random key.  If so, you'll likely need to create the Bin column again, just to keep it sortable.

 

First, I changed the Cumulative Frequency measure to this expression:

Cumulative count = if(HASONEVALUE(Data[LicCnt]),COUNTAX(FILTER(ALL(Data),Data[LicCnt]<=SELECTEDVALUE(Data[LicCnt])),[Count]),BLANK())

Then I set the Inverse Cumulative Frequency measure to this:

Measure1 = SUMX(FILTER(SUMMARIZE(ALL(Data),Data[LicCnt],"Cumulative Count",[Cumulative count]),[LicCnt]>=SELECTEDVALUE(Data[LicCnt])),[Cumulative count])

What this is doing is creating a virtual table where it appends the Cumulative Count to the LicCnt, and then rolls that up to a single table that looks like this:

snipo.PNG

Then it sums the values from this virtual table where the LicCnt is greater than the current value.  This keeps the count when things are re-ordered via sorting, but relies on you being able to sort by LicCnt.

Inv Cumulative Frequency = CALCULATE(COUNT(SampleLicCnts[LicCnt])
                                    ,FILTER(ALL(SampleLicCnts), SampleLicCnts[BIN] >= MAX(SampleLicCnts[Bin])))

 

Also, Is there a specific reason for using the Bin formula, rather than just saying BIN = LicCnt?

HotChilli
Super User
Super User

You are on the right track but you don't need to refer to the original table once you have enough data in your summary table.

InvCumulative Frequency = CALCULATE(SUM(Summary[Cumulative Frequency]),
                                FILTER(ALL(Summary), Summary[Bin] < MAX(Summary[Bin])))

You could re-write your 'Cumulative Frequency' measure to get the data it needs from your summary table too

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.