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.
Hi experts!
I would like to create a new table by using CALCULATETABLE.
Here I would like to get all articles from table 1 if the same article has the status "TRUE" in table 2.
How would you do that?
This approach is not working:
Test =
VAR _Article = CALCULATE(SELECTEDVALUE('Table2'[Article]), 'Table2'[Status] = TRUE())
RETURN
FILTER(CALCULATETABLE(ADDCOLUMNS(SUMMARIZE(Table1, Table1[Article], Table1[OrderNr]), "Value", Table1[Value])), Table1[Article] =_Article)
Hi
To filter the table Table1 based on the values in Table2, you can use the following expression:
This expression first calculates the summary table of Table1, adding a new column Value that contains the values from the Value column of Table1. It then filters this summary table based on the condition that the Article column of Table1 must be present in the list of articles that have Status set to TRUE in Table2.
I hope this helps and mark as solved! Let me know if you have any questions.
@Anonymous : Thanks a lot, but I am not able to add SELECT FROM WHERE into the function.
Is this correct?
@tamerj1 : Not directly. They are related to a common dimension table that contains unique articles.
Hi @joshua1990
Please try
Tabletest =
SUMMARIZECOLUMNS (
DimTable[Article],
Table1[OrderNr],
"Value",
CALCULATE (
SUM ( Table1[Value] ),
Table2[Status] = TRUE (),
CROSSFILTER ( Table2[Article], DimTable[Article], BOTH )
)
)
@tamerj1 : Awesome, that works perfectly fine! Thanks a lot.
What if I want to add multiple value columns from both table 1 and table 2 into this?
How would you do that?
You can try following the same CALCULATE statement for all calculations.
@tamerj1 : Thanks, but that would mean I have to add the filter in every CALCULATE, right?
User | Count |
---|---|
25 | |
10 | |
8 | |
6 | |
5 |
User | Count |
---|---|
31 | |
11 | |
10 | |
10 | |
9 |