Linked tables with slicer - powerbi

I have 1 table
that has these data
ID Code Value Group
1 KJ13 571 Finance,HR
2 KJ82 415 Operation,Finance
3 TF72 454 HR,Operation,Finance
4 KJ58 362 Operation
5 ND77 607 HR,Finance
6 KJ83 350 Operation,HR
7 TF96 531 Finance
8 YT39 840 HR,Finance
9 SS34 976 Finance,HR
10 ND26 155 Operation,Finance
I am filtering by Group through slicer
due to business requirements , slicer has to be in a seperate page
to have slicer for groups
I created a copy of the original table and split it by comma
both the copy and the original one are linked by the ID
my problem is that when I filter by group the origonal table does not filter
I have attached pbix file to make it clearer
https://wetransfer.com/downloads/6fb4c8a43b14ed9455f28e40851d8c5020191025022256/567b8d
I appreciate if some one can tell me how to make original table filter based on the slicer

At the ribbon go to View > Sync slicers. Now you get on the right side your Sync slicers pane. Here you should see your slicer name and the page names. You can check now the checkbox, to sync your slicer from PageA to PageB. This way, if you change the value in the slicer on PageA the charts get also filtered on PageB.

Found the answer in another forum
I am putting it here so it can help someone else with the same problem.
The solution is to change the Relationship between both tables
From Cross filter direction : Single
to
From Cross filter direction : Both

Related

How to deal with multiple ids multiple categories table to reach THIS on Power BI

I have a problem that i was trying to solve 3 days ago and i'm not able to.
I have the following tables:
Companies
company_id
sales
1
2000
2
3000
3
4000
4
1000
Categories
company_id
category
1
medical
1
sports
2
industrial
3
consumption
4
medical
4
consumption
All i want to reach is a COLUMN CHART with a CATEGORY SLICER where i choose the category and i see the TOP 5 companies by category and sales. Yes, in this example the TOP is not needed but in my real case i have 400 companies so i want to:
Select and Show only the required category.
In that category, show only the 5 better companies by sales.
The problem here is Power BI takes all the companies for the TOP N filter so if i choose a category, and also try a top 5, if the companies are not in the TOP5 all companies list, it doesn`t show anything.
Thanks!
If you always want to show the same Top N values in your visual, you can use the filter pane to achieve that.
Below a walk through:
The to add the Top N filtering, I add the following:
It is in Dutch, so a little clarification:
I add a 'filter on this visual'
I selected Populairste N, which is Top N
And as a value I drag and dropped the maximum of sales.
Results:
Things to keep in mind:
You are using a many to many relationship, make sure that this is activated in the Power BI model.
Make sure the direction of filtering is from category to sales, otherwise the slicer will not work. It looks like this:

How does report visual filter work when filter direction is opposite?

1st image shows the model and filter direction.
2nd image shows 3 table visual.
3rd image shows the effect of clicking on account id 11 from the account table causing the filter of the other table visuals.
Image 4 shows the selection of account id 11 in the transaction table. This does not filter the account table since the filter direction is opposite. However, why does it filter the other table (top) ?
Filters propagate "downstream" in the direction of relationships.
Account filters Transaction but
Transaction does not filter Account.
In the top table, your row headers are from Account but your Amount measure is from Transaction. Filtering Transaction[Account ID] does not filter the Account table but it does filter the Transaction table so that the measure returns a blank when it's asked to sum e.g. Markus's amount (since that's not his ID).
Blank results lead to those rows being suppressed. If you added + 0 to your measure to return zero rather than blank, you should still see all the names in the second scenario.

Power BI - Select Slicer Date Between 2 Columns

Hopefully a quick explanation of what I am hoping to accomplish followed by the approach we've been working on for over a year.
Desired Result
I have a table of SCD values with two columns, SCD_Valid_From and SCD_Valid_To. Is there a way to join a date table in my model (or simply use a slicer without a join) in order to be able to choose a specific date that is in between the two SCD columns and have that row of data returned?
Original Table
ID | SCD_Valid_From | SCR_Valid_To | Cost
1 2020-08-01 2020-08-03 5.00
Slicer date chosen is 2020-08-02. I would like this ID=1 record to be returned.
What We've Attempted So Far
We had a consultant come in and help us get Power BI launched last year. His solution was to create an expansion table that would contain a row for every ID/Date combination.
Expanded Original Table
ID | SCD_Valid_Date | Cost
1 2020-08-01 5.00
1 2020-08-02 5.00
1 2020-08-03 5.00
This was happening originally on the Power BI side, and we would use incremental refresh to control how much of this table was getting pushed each day. Long story short, this was extremely inefficient and made the refresh too slow to be effective - for 5 years' worth of data, we would need over 2000 rows per ID just to be able to select a dimensional record.
Is there a way to use a slicer where Power BI can select the records where that selected date falls between dates in two columns of a table?
Let me explain a workaround and I hope this will help you to solve your issue. Let me guess you have below 2 tables-
"Dates" table with column "Date" from where you are generating the date slicer.
"your_main_table" with with column "scd_valid_from" and "scd_valid_to".
Step-1: If you do not have relation between table "Dates" and "your_main_table", this is fine as other wise you have to create a new table like "Dates2". For this work around, you can not have relation between those tables.
In case you have already relation established between those tables, create a new custom table with this below code-
Dates2 =
SELECTCOLUMNS(
Dates,
"Date", Dates[Date]
)
From here, I will consider "Dates2" as source of your Date slicer. But if you have "Date" table with no relation with table "your_main_table", just consider "Dates" in place of "Dates2" in below measures creation. Now, Create these following 4 measures in your table "your_main_table"
1.
date_from_current_row = max(join_using_date_range[SCD_Valid_From])
2.
date_to_current_row = max(join_using_date_range[SCD_Valid_to])
3.
date_selected_in_slicer = SELECTEDVALUE(Dates2[Date])
4.
show_hide_row =
if(
[date_selected_in_slicer] >= [date_from_current_row]
&& [date_selected_in_slicer] <= [date_to_current_row]
,
1,
0
)
Now you have all instruments ready for play. Create your visual using columns from the table "your_main_table"
Final Step: Now just add a visual level filter with the measure "show_hide_row" and set value will show only when "show_hide_row = 1".
The final output will be something like below image-

How to display subgroup totals in a table visual in Power BI?

I need to display subgroup totals in a table visual in Power BI. However, Power BI is showing me incorrect totals. How do I create a measure to show this?
My current table visual is:
My table relationships are:
What I need is:
SiteName LiftName Amount
Site 1 Lift 1 668.00
Site 1 Lift 2 668.00
Site 2 Lift 3 604.00
Site 3 Lift 4 9.54
Site 4 Lift 6 9622.50
Site 4 Lift 8 9622.50
Site 4 Lift 9 9622.50
I have tried adding an inactive relationship and using that with a USERELATIONSHIP function, but it gives me the same as what I have already:
SiteAmount = calculate(sum(Sales[Amount]),USERELATIONSHIP(Sales[SiteID],Sites[SiteID]))
Is there any way to get this table to display as needed? I cannot amend the relationships in the model to link Sales table with Sites table directly. See below PBIX if needed:
https://1drv.ms/u/s!AuiIgc_S9J5JhbYbCO2jbeQPfpzmXw
Cheers
What you want, it seems to me, is the sum of [Amount] without any filtering except for Site. DAX provides the ALLEXCEPT function to do this kind of filtering.
Unfortunately, the field that whose influence we're trying to ignore is part of the relationship to the tables in the visual. So we get some weirdness and I think it's unavoidable. We can ask DAX to hide those rows as a second step.
SiteAmount =
Var Amount = CALCULATE(
SUM(Sales[Amount])
, ALLEXCEPT(Sales,Sites[SiteName]
))
RETURN IF(ISBLANK(SUM(Sales[Amount])),BLANK(), Amount)

How to get latest record for matching ID and date in Power BI Query Editor

I have two tables:
Table A, which indicates where my truck is for each day,
Date Truck Region
5/20/2018 1014 NY
5/21/2018 1014 NJ
and Table B (which contains when my truck inspection was done for each day). Sometimes there may be more than one inspection record, but I only need the last one by truck by day. As you can see, I added a rank column. Truck 1014 has two records for 5/20/2018, but the last one gets ranked as 1 (I will filter the table by 1).
Date Time Truck Rank
5/20/2018 5/20/18 9:00 AM 1014 2
5/20/2018 5/20/18 2:00 PM 1014 1
5/21/2018 5/21/18 2:50 PM 1014 1
I want to merge those two tables together. The reason I ask how to do it in the query editor is that, in the relationship view, you cannot create a relationship on two columns. For example, in my example, I want to join data by date and by truck number, which I cannot. What is the right direction for this situation?
In the query editor, you can use the Merge Queries button under the Home tab.
(You'll need to hold down the Ctrl key to select multiple columns.)
Once you've merged, just expand the columns from Table B that you want to bring over (e.g. Time and Rank). If you did not filter Rank = 1 before merging, you can include it when expanding and filter afterward.
Note that you can also use the LOOKUPVALUE DAX function outside of the query editor. As a new column on Table A:
Time = LOOKUPVALUE('Table B'[Time],
'Table B'[Date], [Date],
'Table B'[Truck], [Truck],
'Table B'[Rank], 1)