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

Percent of total units

Hi all

 

I am having issues with something that should be simple. I need to display the percentage of the total in a bar chart.

My data looks like this:

 

IDDateFilter 1Filter 2Comment 1Comment 2
14/21/2022    
24/21/2022    
34/21/2022  abcdefg
44/21/2022  abcdefg
54/21/2022    
64/21/2022  hijklmnop
74/21/2022  hijklmnop
84/21/2022  hijklmnop
94/22/2022    
104/22/2022  abcdefg
114/22/2022    
124/22/2022    
134/22/2022    
144/22/2022  abcdefg
154/22/2022    
164/23/2022    
174/23/2022    
184/23/2022    
194/23/2022  hijklmnop
204/23/2022    
214/23/2022    
224/23/2022    
234/23/2022  hijklmnop
244/23/2022    
254/23/2022    
264/23/2022    
274/23/2022    
284/23/2022  abcdefg
294/23/2022  abcdefg
304/23/2022  abcdefg
314/24/2022    
324/24/2022  abcdefg
334/24/2022    
344/24/2022    
354/24/2022  abcdefg
364/24/2022  abcdefg
374/24/2022  abcdefg
384/24/2022    
394/24/2022  hijklmnop
404/24/2022    
414/24/2022    
424/24/2022  abcdefg
434/24/2022  abcdefg
444/24/2022  abcdefg
454/24/2022    
464/24/2022    
474/24/2022  abcdefg
484/24/2022  abcdefg
494/24/2022  abcdefg
504/24/2022    

 

Now, what I need to accomplish is this. Once a date or date range is selected via date slicer:

1: Total/ day: distinctcount(ID).

Good done.

2: I need a bar chart that displays: out the daily x number of ID's, what percentage of TOTAL is comment 1:

 

mmicsa_1-1656077595465.png

 

My problem is, I can't reliably calculate (and keep) the value of the DailyTotal.

I tried an intermediary table and doing a CALCULATE and send everything I need as a filter, calculation is correct on the page, once I add it to the chart, it "recalculates" based on category (tables are NOT linked, so actually stumped how)

Tried this: Solved: Trouble with Percent of Overall Total - Microsoft Power BI Community, but unfortunately that example does not take into consideration blanks.

Also tried:

DIVIDE(DISTINCTCOUNT(ID),CALCULATE(Distinctcount(ID),Removefilters(table[Filter1))

DIVIDE(DISTINCTCOUNT(ID),CALCULATE(Distinctcount(ID),ALL(table[Filter1))

They all kinda work ok, but, as soon as I remove the blanks from my BarChart, it also redoes the total ID count, and that is incorrect for my use case.

So basically I am trying to show in the bar chart :

for the date of 4/21/2022, I have a total of 8 ID's, so I expect to see that since abcd has 2 values, it's 25% and hijk with 3 values is 37.5%. 

The blanks WILL NOT be displayed, but still need to be a part of the daily count.

Thanks for any help, been driving me up the wall this one.

4 REPLIES 4
v-rzhou-msft
Community Support
Community Support

Hi @Anonymous ,

 

I think you can try this code to create a measure.

Measure = 
VAR _TOTAL = CALCULATE(DISTINCTCOUNT('Table'[ID]),ALLEXCEPT('Table','Table'[Date]))
RETURN
DIVIDE(CALCULATE(DISTINCTCOUNT('Table'[ID])),_TOTAL)

Result is as below.

RicoZhou_0-1656300205098.png

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Thank you Rico for your reply, unfortunately, doesn't work for me for ... reaons I don't understand, but it has to do with the blanks. 
Please take a look at how it's behaving in my dashboard (but weridly, not in yours):

mmicsa_0-1656310924737.png

So, we have 408 units total for the given day. 

Out of those, we have 402 blanks, and 1 ABCD and 5 HIJK.

If you do the math, it's correct. 1 out of 408  = 0.25 ad 5 out of 408 = 1.2254 ... so correct.

And the blanks are the rest of 98.53%

Now, in the picture below, I just removed the blanks:

mmicsa_1-1656311414878.png

 

As you can see, the result now only reflects the 7 units remaining after the filter has been applied. 
This is the behavior I am trying to overcome but failing to, but curiously, works in yours as I expect it 🤔 

Hi @Anonymous ,

 

I think you can download my attatchment and compare mine data model with yours. If this still couldn't help you solve your problem, please share a sample file with me and show me a screenshot with the result you want. This will make it easier for me to find the solution.

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Hello again

 

Of course I downloaded any looked at your data file, that is why I am perplexed by the results.

Let me come at this from another angle. In your file, you have a Filter on the left visual where you take out the Blanks. That is exactly what I am doing, but for me, it recalculates the percentage (same formula you used).

That is what I am trying to explain in the table. It's literraly the Chart data visualized as a table.

mmicsa_0-1656319600740.png

Would like to upload the PBIX, but it won't let me

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.