I'm currently working with power bi and wanted to filter a factory production site
The site, which is itself divided into zones themselves divided into lines create the hierarchy I have in power bi. ref left of the exemple
On a Pie chart, I'd like to visualize the distribution of values attributed to thoses locations but only to the next layer of the hierarchy. ref right of the exemple
Exemple:
As you can see, selecting S only shows me the next layer of values ie. Z1 and Z2
When selecting Z1 I then have the three lines (L1, L2, L3)
tests I've made so far:
Best I've found is duplicating the hierarchy table and linking the values to there parent ids. So when filtering an element, values connected to it don't show up.
I also tried different approches to hide the deep layers, but can't figure a way to do it, any ideas how to?
update 2 days after posted:
It's been 2 days since I posted and I continued doing some tests, I thought I had a solution by doing a great-parent table of the hierarchy. I would then only have to substract the great-child to childs to have the data I wanted, unfortunatly I couldn't figure it out.
I also tried creating a copy of the table, filtered while created but it doesn't seem to affect the output.
I tried doing some magic with ids but same problem, couldn't find a way to achieve the problem.
Here are my tests data:
hierarchy:
Id
Name
parentId
1
Site
2
Zone1
1
3
Zone2
1
4
Line1
2
5
Line2
2
6
Line3
3
7
Line4
3
Sensor:
Id
Name
hierarchyId
1
Total site
1
2
Total zone1
2
3
Total zone2
3
4
Line1
4
5
Line2
4
6
Line3
5
7
Line4
6
mesures:
SensorId
Name
time
1
240
21/06/2022 10:21:10.000
2
140
21/06/2022 10:21:10.000
3
100
21/06/2022 10:21:10.000
4
70
21/06/2022 10:21:10.000
5
20
21/06/2022 10:21:10.000
6
50
21/06/2022 10:21:10.000
7
100
21/06/2022 10:21:10.000
1
260
21/06/2022 10:31:10.000
2
150
21/06/2022 10:31:10.000
3
110
21/06/2022 10:31:10.000
4
80
21/06/2022 10:31:10.000
5
20
21/06/2022 10:31:10.000
6
50
21/06/2022 10:31:10.000
7
110
21/06/2022 10:31:10.000
1
260
21/06/2022 10:41:10.000
2
160
21/06/2022 10:41:10.000
3
100
21/06/2022 10:41:10.000
4
80
21/06/2022 10:41:10.000
5
20
21/06/2022 10:41:10.000
6
60
21/06/2022 10:41:10.000
7
100
21/06/2022 10:41:10.000
The only way I solved the problem is with a semi-automated solution.
Defining each layer in calculated columns:
diging down the chart with the multiple columns as filters:
It is not fully automated but still do the job. If you have a better solution I'll be happy to see it :)
Related
I am hoping for a formula to take hours from the name columns and sum/average them by week, into a separate table like the 2nd one below. The formulas need to update upon changing the start and end week cells.
Body Part
Start Week
End Week
Arnold (hours)
Usain (hours)
Bob (hours)
Arms
1
3
6
3
0
Legs
1
6
12
36
20
Chest
2
4
6
2
2
Booty
4
6
9
12
3
Core
1
5
10
5
5
Formula Needed:
Hours
Arnold
Usian
Bob
Week 1
6
8
4.33
Week 2
8
8.67
5
Week 3
8
8.67
5
Week 4
9
11.67
6
Week 5
7
11
5.33
Week 6
5
10
4.33
Bonus if there is a way to also quickly average hours by body parts if for example there are multiple Arms rows.
try:
=ARRAYFORMULA(LAMBDA(a, b, QUERY(SPLIT(FLATTEN(BYCOL(D1:F1, LAMBDA(xx, FLATTEN(IF(
IF(a>=SEQUENCE(1, MAX(a)), "Week "&TEXT(SEQUENCE(1, MAX(a))+b, "00"), )="",,
REGEXEXTRACT(OFFSET(xx,,,1), "(.+) \(")&"×"&
IF(a>=SEQUENCE(1, MAX(a)), "Week "&TEXT(SEQUENCE(1, MAX(a))+b, "00"), )&"×"&
QUERY({REGEXEXTRACT(OFFSET(xx,,,1), "(.+) \("); OFFSET(xx,1,,9^9)/(a)}, "offset 1", )))))), "×"),
"select Col2,sum(Col3) where Col3>0 group by Col2 pivot Col1"))
(C2:INDEX(C:C, MAX(ROW(C:C)*(C:C<>"")))-B2:INDEX(B:B, MAX(ROW(B:B)*(B:B<>"")))+1,
B2:INDEX(B:B, MAX(ROW(B:B)*(B:B<>"")))-1))
It seems very simple but I can not get the graph to show the data I want.
So, I have got a lot of IDs with the end and start dates (LENGHT) and open items (OPEN). Each day has got availability (AVAIL) and there is nil used (USED) at day 1.
ID LENGTH OPEN USED AVAIL
1A 6 100 0 2400
I need to create the NEW_DAY column with count of the LENGHT. In this case the result would be
ID LENGTH NEW_DAY OPEN USED AVAIL
1A 6 1 100 0 2400
1A 6 2 100 0 2400
1A 6 3 100 0 2400
1A 6 4 100 0 2400
1A 6 5 100 0 2400
1A 6 6 100 0 2400
Note, I have hundreds of IDs so can not hard code it as 1A and needs to be dynamic.
I am not sure, but maybe this might help you.
If you add a blank query and add this expression:
= List.Repeat({1, 2}, 3)
you will get the first argument {1, 2} repeated three times.
When you separate your ID in a new column and pass this column to the code above (the same goes for the second argument) it might work.
I would like to replace multiple column values at the same time in a dataframe. I would like to change 2 to 1, 1 to 2.
data=data.frmae(store=c(122,323,254,435,654,342,234,344)
,cluster=c(2,2,2,1,1,3,3,3))
The problem in my code is after it changes 2 to 1 , it changes these 1's to 2.
Can I do it in dplyr or sth? Thank you
Desired data set below
store cluster
122 1
323 1
254 1
435 2
654 2
342 3
234 3
344 3
I have a set of individuals with characteristics. Each individual belongs to one or more group. I need to merge individuals to group characteristics, by firstly duplicating each row of individual data set as many times as is given by n_groups.
The data looks like
id age n_groups
1 50 2
2 46 1
3 51 3
4 44 2
I need to have
id age n_groups group_index
1 50 2 1
1 50 2 2
2 46 1 1
3 51 3 1
3 51 3 2
3 51 3 3
4 44 2 1
4 44 2 1
It seems like a very easy task, and I need some variation of expand with variable number of duplicates. Any ideas if there is a simple command for this?
Thanks!
Appears the solution is very standard. The expand command indeed allows for expanding based on variable: expand n_groups solved the question.
I have a Day Strucuture Table, which has following Columns I want to display:
DoW HoD Value
1 1 1
1 2 2
1 3 2
1 4 2
1 5 2
1 6 2
1 7 2
1 8 2
1 9 2
1 10 2
1 11 4
1 12 4
1 13 4
1 14 4
1 15 4
1 16 4
1 17 4
1 18 4
1 19 4
1 20 4
1 21 1
1 22 1
1 23 1
1 24 1
Dow is The Day of Week (Monday etc.), HoD is the Hour of Day and Value is the actual value.
Now I want to Bind this Day Structure Entity Collection directly to a Control so any Changes can be bound TwoWay
Like this Format:
I think the best way to achieve this is to use a Template and/or a converter, but I just dont know how ;)
I already read this article, but Lack of a TwoWay Binding functionality makes it not useful for me :(
I Hope you can help me
Jonny
Again i solved it on my own ;)
For this problem i created a Grid with a fixed amout of rows and columns. Inside this Grid I put a Itemscontrol bound to my List of data. Inside the DataTemplate I placed a Textbox bound to the current value and bound the Grid Row and Columnproperties to the Day of the Week/Hour of Day.
Pro:
The Textbox is TwoWay Databound to a certain Object or Element.
Very Easy to implement if Row and Colum Property is numeric.
Con:
Limited to a fixed amout of Rows/Columns.
Very much Code to write in XAML (Copy and Paste)
Kinda "dirty" Code. Feels not like the best way to do it.
Im still open for other suggestions.