Forum Discussion
Needing some help with how to build this table. Custom Columns.
- 1 year ago
This something like this what you are looking for?
let defaultPID = "25416", Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQwVNJRCk4tKcnMSwcxI5ViddCEjbALGwOZfpjCJkiqTVHN9sMUNsIubIzdEBO4aiNTE0MzbC5HkzDCpcMYlw6oHbEA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [PID = _t, Name = _t, Enabled = _t]), set_types = Table.TransformColumnTypes( Source, { {"PID", Int64.Type}, {"Name", type text}, {"Enabled", type text} } ), defaultTable = Table.SelectRows(Source, each [PID] = defaultPID), merge_tables = Table.NestedJoin( Source, {"Name"}, defaultTable, {"Name"}, "Source", JoinKind.LeftOuter ), expand_default_enabled = Table.ExpandTableColumn( merge_tables, "Source", {"Enabled"}, {"DefaultEnabled"} ), sort_table = Table.Buffer( Table.Sort( expand_default_enabled, { {"PID", Order.Ascending}, {"Name", Order.Ascending} } ) ) in sort_table
You can modify the Power Query code to allow for user selection but if you were to allow your users to pick a PID option from a list in report view they would have to be able to refresh the report in order for the Power Query to update.
That is not usually an option for most reports so you may be able to recreate the solution in DAX so it can exist in the report view without needing to refresh the dataset with each option selection.
One way to do this in DAX would be to create another table that contains the PID options. (25416, 25418, 25420 - make sure the data type matches the type in the original table).
You can then use the selected value of the new table in a measure that mimics the Power Query code.
Here is an example of DAX code that does this...
_DefaultEnabled =
var _rTable =
SELECTCOLUMNS(
FILTER(
all(Query1),
[PID] = SELECTEDVALUE('Table'[PID])
),
"Name", [Name],
"Enabled", [Enabled]
)
var _lTable =
SELECTCOLUMNS(
Query1,
"PID", [PID],
"Name", [Name]
)
var _jTable =
NATURALLEFTOUTERJOIN(_lTable, _rTable)
RETURN
MINX(_jTable,[Enabled])
NOTE: Table[PID] is the new table created with the PID options.
Thank you for all your help. I've been trying to solve for this one last item but cannot seem to get it right. I was able to replicate your setup and that helped a ton. I am able to choose one of the model PIDs and the _defaultenabled column will update accordingly.
Ultimately, I'm hoping to compare one PID on the left against one of the model PIDs.
The piece I cannot figure out is now how can I select a PID on the left to compare against.
An option to select say PID 105, and have it filter down to PID 105 compared against PID 25418 in the _defaultenabled column.
I think I know the problem, just can seem to get it right. If I put a PID Slicer from the full table, anything I select will blank out the compare table. I'm guessing because we're explicitly filtering on a PID. Or, another way, trying to filter based on two PIDs. I've been trying to edit interactions but not getting anywhere.
Is is possible now to add another PID filter for all the PIDs so that a user can choose the PID, then choose the model PID, and see the display as one against the other.
For context, there are over 2000 PIDs, 3 Model PIDs, and 177 Settings, making this a really large display.
I appreciate your help a ton...
- jgeddes10 months agoSuper User
To do this you would need two separate tables for slicing PIDs. The table for selecting the default PID should not be related to the main table. The table for selecting the comparison PID can be related to the main table.
I attached a pbix file with this example model.
- stuntmanpatch10 months agoRegular Visitor
Thank you!!! jgeddes That did the trick. My err was trying to associate the new Default PID table to the matrix. Once I pulled out that mapping it all flows as expected. Thanks again.