The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
I have data like this in two tables as Table1 and Table2, with same columns
In my PowerBI report, I have two filters on Table1's Type and Table2's Type columns like below.
With these two filters selected I want to UNION the resultant filtered result set from Table1 and Table2 as the output.
So I created these two DAX expressions to test the result:
Hi @powerx786
Apparently you can create calculated tables. In this case best is to create a common dimension table that filters both tables.
Types =
DISTINCT (
UNION ( ALLNOBLANKROW ( Table1[Type] ), ALLNOBLANKROW ( Table2[Type] ) )
)
Similarly you can have a dimension date table that filters the date in both tables. Therefore, you can place the date from the date table in the table visual.
Then create a one to many relationship between this table and both tables. You can use this column to slice by in the table visual. Then add the following measure to the same table visual.
Total Amount =
SUM ( Table1[Amount] ) + SUM ( Table2[Amount] )
Please note that the results of both tables will be merged together and aggregated at Type-Date level.
Unfortunately I do not want to create a common dimension that filters both tables, as the idea is to be able to filter both tables using separate filtering conditions.
In the example I just so happened to show one column with same name from both tables, for simplicity. But there could be different filters with different values on either table for the sake of comparing the final calculated table difference between Table1 and Table2 (I will also add a column to indicate if the particular row comes from Table1 or Table2)
Hi @powerx786
I'm just thinking outloud trying to find a reasonable solution without having to dive deep into complex DAX.
Here is one approach.
Index Table = SELECTCOLUMNS ( GENERATESERIES ( 1, MAX ( Table2[Index] ), 1 ), "Index", [Value] )
For text columns
Measure1 = SELECTEDVALUE ( Table1[Column1] ) & SELECTEDVALUE ( Table2[Column1] )
For date or decimal data type columns
Measure2 = SELECTEDVALUE ( Table1[Column2] ) + SELECTEDVALUE ( Table2[Column2] )
Hi,
I am not sure how your datamodel looks like, but in my opinion, slicer selection from the visualization is not influencing the result when creating physical calculated table. If you want to make it happen, one of ways is to insert the condition directly into the formula to create physical calculated table.
I hope this helps.
Thanks.
There is nothing in the data model except two separate tables. There are no further relationships. The slicer in the report is directly referencing the column in the table.
Please try something like below to create a calculated table whether it suits your requirement.
Table4 =
UNION (
CALCULATETABLE ( Table1, Table1[Type] = "A" ),
CALCULATETABLE ( Table2, Table2[Type] = "A" )
)
I do not want to give an explicit value (Table1[Type] = "A") for the filter condition as I want to filter by the value selected in the filter visual