I am using Power BI and need to join two tables, but I want to display only the last result. Below I show more details:
Table1:
number description
263745 Bank reconciliation
Table2:
number status
263745 progress
263745 completed
After joining the tables, the result:
number description status
263745 Bank reconciliation progress
263745 Bank reconciliation completed
But I would like to show only the last result, as below:
number description status
263745 Bank reconciliation completed
What am I doing wrong?
Add an index column to your Table2
Create a calculated column in Table1 like this:
Last Status = LOOKUPVALUE(Table2[status], Table2[number], Table1[number], Table2[id], CALCULATE(MAX(Table2[id]), FILTER(Table2, Table1[number] = Table2[number])))
If you do not have an index column but a date column, simply change the CALCULATE(MAX(...) condition to not get the max id but max date.
If you like, hide the Table2
Related
i have the following table with some sample data similar to what we have in our model:
there will be a date filter called "As Of Date" that will be selected by the user. I will need to create a new measure that filters the above table using these rules each time:
rows where reserve date <= the As Of Date selected by the user
rows that are in "Approved" status
for each combination of Claim Id, Damage Id, and Location Id, get the row with the latest sequence number
sum the reserve value column
so based on the sample data above, if the user select an As Of Date of 8-1-2020, the measure should sum the Reserve Value from the following rows that meet the criteria:
What I am trying to achieve is a measure that would return 900 as that is the sum of the reserve values for the rows that meet the criteria, as listed in the second table above.
Thanks
scott
I am just starting out with PowerBi. Please use the table below as my sample. Assume that the Order Table has a *-1 relationship with Order Status.
I want to create a bar graph to see the number of each Order Status by Month.
The month is at the bottom and each month potentially has 3 bars. 1 bar representing the count of each Order Status for that month.
I need some direction. I know this is an open-ended question, but I at a total loss.
I have created the same tables as you provided and joined them on order status id (*-1 relationship). Then created the status column.
Status = RELATED('Order Status'[Status] )
Dragged and dropped this column on to the clustered column chart under legend and values (default summarised as count). Then got the following visual.
I am fairly new to PowerBI DAX and I want to filter out the top 20 product ids in a measure.
I came up with this formula but it does not seem to be working and I was hoping to get some help here.
$ Amount Parcel =
CALCULATE(
SUM(Data[$ Amount Parcel]),
FILTER (Data, NOT (Data[idProduct], SUM(Data[NetSales])) IN TOPN(20, SUMMARIZE(Data, Data[idProduct], "NetSales", SUM(Data[NetSales]))))
)
I want to show sales per PID for all products except for our 20 best sellers.
Thank you !!
I would suggest an easier approach adding a dimension column.
First of all, you need to have Product dimension table separated from Sales fact table. Make sure to create one-to-many relationship between Product and Sales with "Single" cross filter direction.
Then you can create a calculated column on Product table, which can be used to filter out top selling products.
Sales Rank = RANKX('Product', CALCULATE(SUM(Sales[SalesAmount])))
Now drag and drop Sales Rank field into the Filters pane of your visualization, and set the filter condition so that top selling products will not be shown.
I want to do countif in PowerBI (Example: count of total item with condition #1: having transaction of 2 or more, condition #2: year)
I have sample data comprised of PO (transaction) #, item #, date (year), item description, ship to location.
I can achieve the result through Excel - Pivot a matrix table of rows of items, columns of year and the value is count of PO/transactions. A separate table on the side is utilized to count the total item within Column (Years) that has transaction count > 2.
I can't figure out what DAX to use in PowerBI to achieve the same thing as I could with Excel:
Sample of transaction counts:
Usually COUNTIFS in Excel are implemented by use of CALCULATE(<expression>,<filter1>,<filter2>…) in Power BI, for example:
CALCULATE(SUM(Table1[Column1]), FILTER(Table1, Table1[Column1] < Table1[Column2]))
Read more details here.
I'm trying to merge 2 queries in Power BI Desktop, matching rows based off a user and date column in one query to a row in the other query, where the user matches and the date in the 2nd query is the closest one before the date in the 1st query.
In other scenarios I need to match on more than one column, I'll usually create a composite key to match, but here's it's not a direct match.
Examples of the 2 queries are:
QUERY1
User Activity Activity Date
User 1 Activity 1 2019-01-24
User 1 Activity 2 2019-03-03
User 1 Activity 3 2019-04-17
QUERY2
User Status Status Change Date
User 1 Status 1 2019-02-05
User 1 Status 2 2019-03-06
User 1 Status 3 2019-04-05
And the merged query I'm looking for is:
MERGED QUERY
User Activity Activity Date Status
User 1 Activity 1 2019-01-24
User 1 Activity 2 2019-03-03 Status 1
User 1 Activity 3 2019-04-17 Status 3
Both queries are sourced from a REST API. If it was a SQL source, I'd use a SQL query to create a derived island table of start and stop dates based on Query2 and do a BETWEEN join against Query1 and have that be the source for Power BI.
Within the Power Query Editor, how would I get to the merged query result?
First, you want to do as you suggested and modify the status table to have start and stop dates instead of Status Change Date. You can do this by sorting, indexing, and self-merging as I've previously explained here and here.
Once you have that, you can load a copy of the status table in each row and use the User and Date columns to filter the table and finally return a single value for Status.
let
Source = <Query1 Source>
#"Added Custom" =
Table.AddColumn(Source, "Status",
(C) => List.First(
Table.SelectRows(Status,
each [User] = C[User] and
[Start] < C[Date] and
([Stop] = null or C[Date] <= [Stop])
)[Status]
),
type text)
in
#"Added Custom"
This says we take the Status table and filter it so that based on the current row the User matches and the Date is between Start and Stop. From that filtered table, we select the Status column, which is a list data type, so we pick the first element of the list to get the text value of the only member of the list.