PowerBI - Duplicate Entries in Query - powerbi

I have created a query on three tables. Here there is a column GUID (which is actually unique), then there is a column date/time and a column with a phone number.
Now if the same phone number calls more than once, get duplicates with always the same GUID. Can I filter this in Power BI so that the ID only appears once?

If I understand your requirement correct, There is an option in Power Query Editor to remove all duplicate rows. You can first select your all 3 columns- guid, date_time and phone_number. Now right click on any of the Column's header and select Remove Duplicate from the list as shown in the below sample image-
This should keep only 1 rows per distinct combination considering 3 columns.

Related

How to build relationship based on range of dates (periods) in Power BI

I'm trying to figure out the best way to build a relationship from a table that has records in a daily format (one record represents a single date) to a table that contains records in a date-range format (one record has a start-date and end-date, consequentially representing a period or range of dates).
Since my actual datafiles contain work-related information, I created 2 demo tables that contain dummy data that reflects the date columns in question.
Here is my DailyDate table
Here is my DateRanges table
Here is the current model view
I would like to be able to have a relationship built between the tables so that if I were to have 2 tables/matrices in the Report view, with one table showing the Daily Date Data and the other table showing the Ranged Data Data, I would be able to select a record in the Daily table and Power BI's highlight functionality would filter the records in the Ranged table so that only date ranges containing my selected date appear, and vice-versa (if possible).
For example, referencing this screenshot, if I were to select index 0 in the 'Daily Data Data' table, the 'Ranged Date Data' table should be filtered to only show records with index of 0 in the other table. If I were to select Index 2 (01/03/2022) in the Daily Date Data table then the Ranged Date Data table should be filtered to only show indices (0, 1).
In the model view, when trying to build this relationship, I can create a relationship from DailyDates.Date to DateRanges.StartDate and then from DailyDates.Date to DateRanges.EndDate; however, only a single relationship can be active so the highlight and slicer functionality will not give me the results I'm looking for.
As you can see from this demo, the datasets are small; however, my actual datasets contain around 50 million records in the Daily table and 10+ million records in teh Ranged table, so I'm hoping there can be an efficient method of getting this functionality that will not be too much of a load on memory.
Any advice into how to accomplish this would be greatly appreciated.

'OR' Filtering on Columns in PowerBI

I've got an oddly set up google sheet as my data source for a powerBI dashboard. Right now my main stress point is a 'last 7 days' filter that needs to be applied. The problem is that there are multiple columns containing dates that could be in the last 7 days, in this case representing multiple steps in an email chain.
If any one of those columns contains a date in the last 7 days, then I need to capture the row in most of my visualizations and tables, but if I just use standard filters, PowerBI assumes 'AND' and displays none of the rows, since there will almost never be a row where multiple date entries are in the last 7 days.
I'm almost certain there is a way to do this with either merged columns or calculated fields, or maybe there is even something as simple as an 'OR' filter, but thus far my googling has not turned up anything. Do you know a work around for this?
Thanks in advance!
In Power Query Editor, create a duplicate column for each of your date fields.
Make sure each of the duplicated columns is in Date format and then calculate the "Age". You will get a time value. In the Transform pane, use the "Duration" function and convert to "Days". Do this for each of the duplicated columns.
Now the last step: Create a "conditional column" in the "Add column" pane, and pull all of these new columns that should now have integer values and set the condition to show "Yes" if less than or equal to 7, "No" if more than 7.
Let me know if this helps.

How to create table based on minimum date from other table in DAX?

I want to create a second table from the first table using filters with dates and other variables as follows. How can I create this?
Following is the expected table and original table,
Go to Edit Queries. Lets say our base table is named RawData. Add a blank query and use this expression to copy your RawData table:
=RawData
The new table will be RawDataGrouped. Now select the new table and go to Home > Group By and use the following settings:
The result will be the following table. Note that I didnt use the exactly values you used to keep this sample at a miminum effort:
You also can now create a relationship between this two tables (by the Index column) to use cross filtering between them.
You could show the grouped data and use the relationship to display the RawDate in a subreport (or custom tooltip) for example.
I assume you are looking for a calculated table. Below is the workaround for the same,
In Query Editor you can create a duplicate table of the existing (Original) table and select the Date Filter -> Is Earliest option by clicking right corner of the Date column in new duplicate table. Now your table should contain only the rows which are having minimum date for the column.
Note: This table is dynamic and will give subsequent results based on data changes in the original table, but you to have refresh both the table.
Original Table:
Desired Table:
When I have added new column into it, post to refreshing dataset I have got below result (This implies, it is doing recalculation based on each data change in the original source)
New data entry:
Output:

Comparing 2 Tables in PowerBI

Working on a way to compare 2 tables in PowerBI.
I'm joining the 2 tables using the primary key and making custom columns that compare if the old and new are equal.
This doesn't seem like the most efficient way of doing things, and I can't even color code the matrix because some values aren't integers.
Any suggestions?
I did a big project like this last year, comparing two versions of a data warehouse (SQL database).
I tackled most of it in the Query Editor (actually using Power Query for Excel, but that's the same as PBI's Query Editor).
My key technique was to first create a Query for each table, and use Unpivot Other Columns on everything apart from the Primary Key columns. This transforms it into rows of Attribute, Value. You can filter Attribute to just the columns you want to compare.
Then in a new Query you can Merge & Expand the "old" and "new" Queries, joining on on the Primary Key columns + the Attribute column. Then add Filter or Add Column steps to get to your final output.

Google charts table random display

I have multiple tables in my app. In the app I cannot control the numbers of columns of the strings lengths in the column. Also I cannot control the numbers of columns of the orders of the columns.
Right now i have 4 tables in a set and one table in another set. I will put only the headers as the other data is confidential in this image.
The problem I encounter is: since the string length in a column in the table is not the same as the same column in other table. The width of the columns are not the same within a table set. I have tried to check on page load the length of the columns but the tables is not drawn on page load. When i say a table set i refer a list of tables with same properties, same columns number and name.
I cannot set fixed size on a certain column because I am not able to know if for next table set how the columns distribution is.
How can I make all the columns to look alike? How can I catch event when the table is fully drawn?