power bi load rows based on condition in Query editor - powerbi

I have the blow data
create table #tbl (Continet varchar(40), Country varchar(40), City varchar(40), OrderDate date)
insert into #tbl values
('South America', 'Colombia', 'Angostura', '2020-05-13'),
('Europe','Germany','Thuringia','2019-02-12'),
('Asia','China','Tianjin','2017-11-22'),
('Asia','India ','Hyderabad','2018-02-15'),
('Asia','China','Tianjin','2016-10-30'),
('Europe','United Kingdom', 'Northwich','2015-05-03')
select * from #tbl
drop table #tbl
I am taking the data to power BI and the rows are in millions.
what i want is to Filter the data in Power BI query editor to load only India Data. The data is from google analytics, for simplicity i use sql to give the above data. How can i do it in power query editor
Thanks

Assuming that you know what a sql view is.
Make an sql view -with a proper where- and feed power-bi with its result.

Related

Filtering by Power BI measure not working unless the date column is added to the table

In my Power BI model, I have written a measure to filter the data by the latest date in the model:
LatestDateIndicator = IF(CALCULATE(MAX('Table1'[WeekOf]),REMOVEFILTERS('Table1'))=MAX('wf WeeklyData'[Table1]),1,0)
In the visual filters, I select "greater than 0" to select rows only with the latest date in a date column called WeekOf. It does not work unless I add the column WeekOf to the table.
How can I make it work without adding the column WeekOf to the visual table?

Slicer Only Show Month / Year and Filter On That

I have a table with a value ReportDate, which is in the format '03/01/2020'. I want to create a slicer in my Power BI report that displays only the format '03/2020' and the user can then select the value of the month and year to display, and it will display the data for that month (regardless of the day value). How would one go about doing this? I know technically I can add a new column in the database table, but unfortunately I do not have access to changes in the database and as such, would like a Power BI solution.
In the Power Query Editor create a new column with formula
Date.ToText([Date], "MM") & "/" & Date.ToText([Date], "yyyy")
Change [Date] to whatever your date column is called. Date.ToText converts a date time to text, which is then concatenated. You can then filter on that column. For issues like this it is best to have some sort of calendar table.
You can create a new column in using query editor in power bi:
mon_year = left(<column_name>, 3) & Right(<column_name>, 4)
Note: Make sure your are connected to dataset in import mode because in live connection you will not be able to create New Column in Power BI.

Power BI slicer filter on FK field on power bi report

Let's suppose this data structure:
Customers (cust_id and cust_name)
Invoices (invoice_id, cust_id, date)
I want to show invoices in a table component on a report.
I have add a slicer, because i want to filter this table by customer.
I have dragged Invoces > cust_id field into this slicer.
What i want to do is to display cust_name into this slicer.
How can i do this ?
Thanks

How to display Subtraction of two fields and display as a column in PowerBI?

I am using SQL server data base. I need to display total no of nights based on checkindate and checkout date. i am new in Power BI.
I tried by quick measure but it is not working.
You can do this in different ways - calculate the duration in the database, add custom column in M or column in DAX.
In SQL Server use select query like this:
select checkindate, checkoutdate, datediff(day, checkindate, checkoutdate) as duration from table
In M (Power Query) - click Edit queries to open Power Query editor and then Add Column -> Custom column:
Duration.Days(Duration.From([checkoutdate]-[checkindate]))
In DAX - right click your table and select New column:
Duration_DAX = DATEDIFF('Table'[checkoutdate]; 'Table'[checkindate]; DAY)
Note, that depending on your settings, you may have to use comma (,) instead of semicolon (;) in the DAX expression above.

Dax: How to apply filter function on a column?

I am trying to create a report and i have a table of data which is having project name,pro id,emp name,id, location(off/onsite) like all are basic info about the each employee.
I am using RLS so that when ever a person can login to this report he can view their own personal data.
When i login to this report, then i can able to see the project id's which are having under my list.
Now i am trying to show the basic emp details in a table like as emp name, id, role and location.
But in table i can see the only value of the person who login to the report.
I cant see the rest of employees which are belong to the same project id and their info in table.
I have tried a dax using calculated table funtion as below for only single pro id by using NEW TABLE option.
Table =
CALCULATETABLE(
SUMMARIZE('Basic Info','Basic Info'[Employee ID],'Basic Info'[Employee Role],'Basic Info'[Employee Name]),
FILTER('Basic Info','Basic Info'[Project ID]="C.0010978"
))
And it is giving the output for that perticular project.
But if i remove that hard coded pro id and put column of the pro id from table as
Table =
CALCULATETABLE(
SUMMARIZE('Basic Info','Basic Info'[Employee ID],'Basic Info'[Employee Role],'Basic Info'[Employee Name]),
FILTER('Basic Info','Basic Info'[Project ID]='Basic Info'[Project ID]
))
then it is not filtering the values as the projects filtered from the slicer as show in above image.
It is showing all the emp names and their data.
Any suggestions.
Thanks in advance,
Mohan V.
You cannot use slicer values in a calculated column. Calculated columns are evaluated during the data load and are not responsive to any visuals, filters, or slicers.
You may want to try using a measure instead of a calculated column.
Try searching the web for "power bi column vs measure" for more info on how each one is used.