I would like to get a single value from "table2.MappedValue" for every record in table1 in Power Query Editor,
I have two tables, that have a many to one relationship, table2 is just a mapping table:
table1: ID | Values
table2: ID | MappedValue
when I try Table.Column(#"table2","MappedValue"), I get a list and not a single value.
I can do that from Table tools-> New Column, but I was wondering if that is possible in Power Query Editor.
You can do this by merging queries. In the query editor go to Home tab and select table1 click on merge and merge with table2. Next step is to expand your new column by selecting the dubble arrow in the column and select the column you want.
Related
I am learning power BI , for one of my requirement i want to filter table based on the selected value from the slicer and show it in different slicer.
So, here there are 4 slicer and based on selection of one slicer i have to populate the data for the 2nd.
My Table Looks Like
id Name ParentId
1 A null
2 A.1 1
3 A.1.B.1 2
So, i have only 1 table where i have to search the element by id -> parentId and then populate it in the next slicer.
e.g: if We select A then in the next slicer we should show A.1 since , id --> 1(A) = ParentId --> 1(A.1)
I tried to create separate table and then link the id with parentid in the mapping section , this concept is working but not the problem is .
If we select A then in 2nd combo A.1 and A.2 is displaying , but as we click on A.1 on the 2nd combo and then try to click on the elements on 1st combo here in our case A , then the filter is not working properly .
If appending the elements from previous selection + New selection
e.g:
Slicer 1 Slicer 2
A -- (1,2,3)
B -- (4,5,6)
Now , after clicking on A[1st Slicer] it shows (1,2,3) [2nd Slicer]
After clicking on 2 [2nd Slicer] --> showing some elements in [3rd
slicer]
But, now again click on B [1st slicer] --> [4,5,6,2] (Wrong value)
since we selected 2 its appending with the new selection only if we
click on the 2nd slicer.
So, as an alternate solution I tried to filter the selected value which is measure from the table and then show it in the list.
My expression:
Table = FILTER(TableA, TableA[id] == Tableb[selectedId] )
Tableb[selectedId] --> is measure
Table = FILTER(TableA, TableA[id] == "8DE04141-E5B6-49E1-814A-ADB4C6FF5DCF" ) --> selected Id
1st statement is not showing any value but the 2nd giving me the result when i am hard coding value , please suggest me what i can do here.
i want to filter table based on the selected value from the slicer and show it in different slicer.
You don't need DAX for that. You just set up the correct relationships and set filters and slicers in the report.
I have a Redshift table I want to alter adding a new column, which values are derived from an existing column on the table.
Basically, only adding a column "year" which extracts the year from the column "snapshot_date".
Any ideas how to achieve that? Tried following code, but it errors out.
ALTER TABLE test_schema.table_name ADD year AS ( extract(year from snapshot_date) );
I'm trying to create a new table using the existing table using the DAX query of PowerBI, Is there any Best options?
My table is
There are multiple ways to do this.
You can create a calculated table using DAX from Modelling > New Table and write DAX expression like:
MonthlySum = SUMMARIZE(SAP_INCURRED,SAP_INCURRED[Posting Date].[Month],SAP_INCURRED[amount])
enter image description here
Another option is just duplicate an existing table from Query Editor
Query Editor > Select a table and right click > Select Duplicate
enter image description here
Go to the Modeling tab and select a new table option
You will get the DAX query edit option something below
Query: Write your query to create a new table from an existing table
CustomerOccupation = SUMMARIZE('KPIMapReduce?limit=10000&stale=false&connection_timeout=60000&inclusive_end=true','KPIMapReduce?limit=10000&stale=false&connection_timeout=60000&inclusive_end=true'[CustomergetOccupation],'KPIMapReduce?limit=10000&stale=false&connection_timeout=60000&inclusive_end=true'[ClerkCount],'KPIMapReduce?limit=10000&stale=false&connection_timeout=60000&inclusive_end=true'[DriverCount],'KPIMapReduce?limit=10000&stale=false&connection_timeout=60000&inclusive_end=true'[FarmerCount],'KPIMapReduce?limit=10000&stale=false&connection_timeout=60000&inclusive_end=true'[WorkerCount],'KPIMapReduce?limit=10000&stale=false&connection_timeout=60000&inclusive_end=true'[OthersCount])
Result: Our new table is ready
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.
I would like to create a table to compare Month To Date (MTD) Vs YTD Sales data metrics
I am using two queries:
1st query = YTD Sales data (Two fields: Sales and Quotes)
2nd query = MTD Sales Data (Two Fields: Sales and Quotes).
Each query has the same field names, just different data
I would like to output a table like the following
How to I create the above table? At the moment I can only create a table like the following:
The latter 1x4 table only works if I appropriately name the fields. But definitely isn’t what I want, because with enough fields, the table could go on forever.
Any help would be appreciated
In the query editor, create a label column for each table that labels what they are and then append the two tables together so you get something like this:
Then you can create a matrix visual with the Label column in the Columns field and the Sales and Quantity columns in the Values area.
Make sure you've switched "Show on Rows" to "On" under the Format > Values section of the Visualizations pane.