How to get sum of distinct values in Power BI? - powerbi

Example, I have the below column where I need to add only the unique values.
number
44
44
55
55
66
66

You can do this fairly simply with a measure.
Distinct Sum = SUMX(DISTINCT(Table1[number]), Table1[number])
The DISTINCT function creates a list of distinct values in the specified column. Then SUMX goes through this list one at a time and adds Table1[number] for each row.

I'm assuming you mean that you'd like the sum of 44+55+66=165.
To me it seems that the best approach is to build a new table using the measure unique = DISTINCT(Table1[number]). You could add it as a measeure in an existing table, but it will most likely cause troubles in your visualizations.
So if you have a table like this:
Then you can go to the Report tab and select Modeling > New Table and insert the formula above.
And then you can easily display the total in a Table or Matrix visualization like this:

Related

Table visual is unintuitively aggregating my data

I am loading an Excel file, in which it has 43 rows, all the rows are identical. This is the only file I'm loading and there are no connections relationships in the model whatsoever.
When I plot my data into a table visual, and choose not to summarize any of my fields, Power BI still shows me one row. While if I change any of the field to do a count of it, it shows me correctly that I have 43 rows. I need to be able to see all the 43 rows in my table.
Why is Power BI summarizing my data even if I command it not to do so?
Am I missing something simple?
Input table as seen in Power BI data tab:
The visual I'm trying to create:
The table visual in Power BI behaves similar to a Pivot Table in Excel.
W/o an aggregation defined, the "Values" fields behave like "Rows" in a Pivot Table and you will only see distinct items or distinct item combinations. You have 43 identical records, hence it is represented as one row in the visual.
With an aggregation defined (Sum, Count, ...) the field behaves like "Values" in a Pivot Table, and you get the result of that aggregation, filtered by the distinct items/combinations to the left, which is again one row in your case.
If you just want to show all the records in a table visual, you'll have to make them unique. The easiest way to achieve that is by adding an index column in PowerQuery and then also showing that index in the table visual.
However, this is not exactly what Power BI is made for and you are probably better off by switching to something like PowerPoint instead.
And btw., newer show sceenshots in stackoverflow, always provide sample data instead.

Power BI: Append similar table but null in custom column

I have a table in Power BI which I'm working with. In this table I have some regular columns with values and I've created a custom column with a very simple formula. In this example the custom column is the result of A + B.
Column A Column B Custom Column
0 20 5 25
1 30 10 40
2 10 20 30
My problem is when in the Power Query Editor I try to append a new table with the same structure of columns of the main one but it appears null in the values of the custom column. This new table contains as well Column A and Column B but in the Custom it doesn't appear the result A + B but it appears 'Null'.
Is there any way of solve this? I mean, when I add a new table automatically it shows the values in custom columns instead of 'Null'. Thanks in advance.
If I get your issue correct, you are performing the "Add Custom Column" steps before you are appending both table. You can just change steps sequence between "Add Custom Column" and "Append Table".
First perform the "Append Table" step and then add the step "Add Custom Column". This will solve your issue.
Here is your case-
Here is after altering the steps-

How to create new table and give color coding for difference value by subtraction of today table value from yesterday same table value on PowerBI?

I'm trying to automate creating the difference value table from Today table value and the Yesterday table value and also give color coding for different values in the new table.
Yesterday Table
EntityType A Count
X 23
Y 45
Z 12
Today Table
EntityType A Count
X 33
Y 46
Z 12
And my new table would be
My doubt is how we implement using PowerBI, we have to use DAX or any other custom option is there?
I'm writing the procedure here to get the difference between yesterday's table count and today's table count.
First, create four tables
Then we have to create the many-one(*<->1) relation between those tables
We have to create a new column difference on today table
CDC Change = VALUE(RELATED(yesterdayDataBucketCount[KPI_Value])- todayDataBucketCount[KPI_Value])
For Color coding on the table, we have to create a rule by selecting the value
1.Number value column
2.String value column
And my new table would be

Power BI Countif between two tables

Hello Stackoverflow community,
I am a novice in Power BI DAX syntax writing and am desperate for assistance on a problem at work.
Here's the short of it: I have one table which has the RAW data being pulled from Smartsheet. I have a second table I made for a weighted calculation which I cannot figure out how to write.
In this other table I made, I'll call it WEIGHTEDTABLE, I have a [Brand] column with text I typed in when I made the table (Brand1, Brand2, etc). Then I have two columns which I would like to populate with a formula. These two other columns are for Item1 and Item2.
The reason behind this is I can have a graph with just counts of Item1 and Item2 for each brand, but that is not fair/accurate because some brands have more of an item than another (which is why I want to created a WEIGHTED table).
The graph I want to create would have the Brands on the Axis, and the values would be the COUNT of Item1 and Item2 / the appropriate number that I will enter (let's just say it's 25 for Item1 and 10 for Item2).
So ideally, it would be a COUNTIF or IF - if [Brand] from the RAW table = [Brand] from the table I entered, then there would be a COUNT of Item1 from the RAW table divided ( / ) by a 25 or 10.
That's it! Perhaps there is a much easier way to do this. Anything helps and I really appreciate the time and effort that goes into responses!

DAX way to return summarised data

I hope I'm not missing an easy solution am still getting used to DAX and can't yet find an appropriate logic.
I have a large dataset, >10m rows which I want to test. An identifier column "DocumentNumber" might occur on multiple rows and I want to find where the sum of "Value" over these rows for a given "DocumentNumber" is non-zero.
Tried to use PowerQuery > removed all but these two columns > Group By > DocumentNumber > Sum of Value. However my 32 bit version of Excel appears to run out of memory performing this step Expression.Error: Evaluation ran out of memory and can't continue.
Wrote a DAX measure > Sum of Values and dropped into a pivot table with a view to filtering out the zero values but when I try to drag in the DocumentNumber to rows there are more than a million rows so the table won't render.
Is there a logic I should follow in DAX that would achieve step 2 before bringing it to the pivot table? Can DAX actually create a new table in the data model which is the aggregated and filtered data rather than using a pivot? I believe this is possible in PowerBI but not sure about Excel evironment.