Power Bi, Return percentage of grand total but the column's values are text - powerbi

I am trying to return the percentage of the grand total from #number of clients using the second and fourth columns. The number of clients values are text and are collected using Count('Table'[Column]). That is where I have run into issues. When I try Countrows() or AllSelected() to try and work around it, it returns all the rows and doesn't keep the filters I have set.
My current measures:
Client Total = COUNTA('Table'[Client_Name])
% with at least 1 document = DIVIDE(SUM('Table'[At Least 1 Document Sum]), [Client Total])
Right now, it only calculates the percentage based on the filtered # of clients in the same row versus the grand total. I am hoping to have it use a dynamic grand total that is shown at the bottom of the table.
[Current Table] (https://i.stack.imgur.com/IG254.png)

Here is my solve
Measure Name = CALCULATE(COUNTROWS('Table'),ALLSELECTED('Table'))
Then:
Measure Name = SUM('Table'[At Least 1 Document Sum])/'Table'[Measure]

Related

Getting correct Sum for total row DAX Power BI

I have:
Dim Table:
Accounts: customer granularity level.
Fact Table:
PhoneCalls. calls to customers granularity level.
I need to create and see the number of calls made to a customer up until the customer made their first deposit.
I was able to do this on the customer level but on the Total level I get a weird result:
my measure:
ACC_Calls_2_FDP =
CALCULATE(
COUNTROWS(PhoneCalls),
PhoneCalls[disposition] = "ANSWERED", -- only calls that were answered
PhoneCalls[calldate] <= MAX(Accounts[FDP_Date]), -- up until FDP date per customer
USERELATIONSHIP(Accounts[AccountNo],PhoneCalls[AccountNo]) -- make the connection active
)
the results are:
On the total level i was expecting to see 14. not 536
what is going on? what am i missing?
The data model:
Filter direction: Accounts filters PhoneCalls
Cardinality 1:*
Power BI doesn't sum up each of the row values as in Excel. Instead, for Grand total value they will still calculate it as a row itself with no filters on AccountNo on it.
In this case, the max value of FDP_Date in the whole table is taken in the measure. So for example, ACC 1 has max date of 3, ACC 3 has the max of 10. The grand total calculation will use 10 as the max value and start countrows on whichever rows with FDP_Date < 10.
To fix this is tricky as I don't have any other information than this. However, I hope this explains you well of the "bug".

In PowerBI what options are there to hide/redact/mask values in visuals to anonymise data

What options are there in PowerBI to suppress, redact or hide values to anonymise values in reports and visuals without loosing detail and have that restriction apply to multiple pages in a report?
Cat
Count
%
Category 1
23
10
Category 2
2
0.9%
Category 3
4
1.7%
So that its possible to keep the rows but end up with a placeholder where count is <4 and % is greater than 1% but less than 2%
Cat
Count
%
Category 1
23
10
Category 2
*
0.9%
Category 3
4
*
So far my experience has been
a measure with a filter applied will hide rows but you can't apply a measure filter to an entire page or all report pages.
Ive seen mention of conditional formatting to hide the value by having the font and background the same colour but that seems open to error and labour intensive.
I also want to be clear when a value has been suppressed or masked
I suspect there is a more better way but I haven't been able to figure out where to even start.
OK, I have something working but you will need Tabular Editor to create a calculation group. Here are the steps.
I'm using the following table (named "Table") as the source data.
Add two measures (calculation groups only work on measures) as follows.
% Measure = SUM('Table'[%])
Count Measure = SUM('Table'[Count ])
Open tabular editor and create a new calculation group named "CG" with a calculation item named "Mask". Paste the following code into the calculation item.
if (
(selectedmeasurename() = "% Measure" && selectedmeasure() >1 && selectedmeasure() <2)
||
(selectedmeasurename() = "Count Measure" && selectedmeasure() <4)
,"*",selectedmeasure()
)
4. Save the calculation group and in Power BI drag the name column onto the filter for all pages as follows, ensuring it is selected:
The masking will now happen across all reports automatically. Below you can see the same table on two different reports which have now been successfully masked.
It depends on your data connection type as to whether this is available, but a calculated column (instead of a measure) can be used as a filter at the "this page" or "all pages" level.
If this option is available, then you can find it right next to the "New Measure" field.
Using this and your sample data above, I created a couple of calculated columns and show the resulting table. You can then display these columns and use them as filters throughout the report. Your DAX may be slightly different depending on how the actual data is formatted and such.
Count Calculated Column
Masked Count =
IF(
'Table'[Count] < 4,
"*",
CONVERT('Table'[Count], STRING)
)
% Calculated Column
Masked % =
IF(
'Table'[%] > .01 && 'Table'[%] < .02,
"*",
CONVERT('Table'[%] * 100, STRING) & "%"
)
Resulting Table
Example of how the filter can be used
The values of these columns will update as your data source is refreshed in Power BI. However, calculated columns aren't available for Live Connection, in which case you would have to do this kind of logic at a lower level (in Analysis Services for example).
Additionally, you could potentially use Power Query Editor to accomplish this kind of thing.

Creating and Referring to a Grand total for a future calculation in Power BI

Attach is a screenshot of my tables and columns/values I have. I am very new to power BI and have searched for a solution to my problem but it all leads to a running total which I does not solve my issue.
I am trying to create a future calculated measure that needs to reference a grand total of total meals as so (grand total total meals * Fairshare %). I could create a column/measure with the grand total written into the equation but i would like to have this column dynamically change since new data will be updated on a monthly basis. The logic should be to have the new column just refer to the grand total meals (whatever value it is; 788150 in this case) multiplied with fairshare % column for each row but I can't see a way to refer to a grand total in power BI.
Let's say you have a DAX measure of:
Total Meals = [KC_Total_Meal] + [WPP_Total_Meals] + [SP_Total_meals]
That measure when it's calculated will be adjusted by the row context in your table. (I'm assuming you have a date or location to the left of your screen print.) If you are new to "context" in Power BI, try reading through this helpful reference card.
To remove the row context to get a true Grand Total, use the ALL() function within a CALCULATE() function. ALL() returns all the rows in a table ignoring any filters or row/column context that might have been applied.
Grand Total Meals = CALCULATE( [Total Meals]), ALL(Meals_Table))
Depending on the situation, you may need similar functions such as ALLEXCEPT() or EARLIER() or REMOVEFILTERS().

How to show the total values of rows in a Matrix with number value having my columns values as percentage

I've started to manage PowerBi from a couple of weeks so i'm a little bit confused about some things.
My problem is that i need a Matrix in my dashboard with percent values but i want the total in number value because the total of a percent of row shows me always 100% and i dont know about the number i'm working
This is my Matrix with percentage values
This is how i want the total of row returns me but with the columns values ins percentage
I've tried to make a measure counting the values
COUNT(OPSRespuestas[answer])
After that turn off the total of rows and add this measure to the values in my matrix but this is what i get
This is my table after trying add a measure with the total
It returns me the total for each of the columns and not the total of all my rows.
These are the tables i'm working with
This my top header values
This is my left header values
The answer column is what i need to count
This is my relationship between this 3 tables although i have many more intermediate table aside from this 3 as you're going to see in the next picture:
My relationship tables
So finally what i need is that this matrix shows me the total of answer in percentage for each of departments and group of questions and then show me total by department but with number value
The problem you are experiencing has to do with context. Each row is seen as it own total population hence the 100% total. Each column in this row is evaluated against the total of that row to provide a percentage value.
In addition to adding a custom measure to replace the total, you could also consider computing a percentage against the grand total of all dimensions. This means that each cell gets evaluated against the the total of all rows and columns. In this ways the cell value would change compared to your first table but the row total does not evaluate to 100% anymore.
SUM ( [Value] ) / CALCULATE ( SUM ( [Value] ) ; ALL ( 'Your Table' ) )

Running total not aggregating on line chart

A table with some sales data has an associated running total measure. When viewed in Data view of PowerBi Desktop the data does reflect an aggregated total.
However when applied to a line chart the running total is simply the monthly totals. The expectation would be that a running total never decreases (assuming only positive sales) and that the line chart would reflect the values in the measure. So month by month should actually be 500, 1500, 3000.
Update 1: As per Foxans suggestion - same result:
Update 2: Works when using an index instead of a date (dd/MM/yyyy):
You ISONORAFTER filter should be based on Date instead of Spend for a running total (Or in the absence of a date column, should be the column which can identify the order you're trying to summarize, e.g. an incremental index), i.e.
Spend running total in Date =
CALCULATE(
SUM(Spend[Spend]),
FILTER(
ALLSELECTED(Spend),
ISONORAFTER(Spend[Date], MAX(Spend[Date]), DESC)
)
)
It's causing some confusion here because your sample data in Spend column is coincidentally in ascending order of values (100 -> 200 -> 300). If you update it to some random data, you'll notice it won't work in the first place.