Forum Discussion
Filtrer in one line
- 1 year ago
Here is the update of the topic :
So i modify my code :CombinedTable2 =
UNION(
SELECTCOLUMNS(
SUMMARIZE(
FILTER(ALL('PCA'); 'PCA'[IsAggregateRow] = 1);
'PCA'[SOCIETE]; PCA[CJOURNAL]; PCA[DTECRIT]; PCA[ANALYT]; --here is the modify i add all the column i need on this line of the code
"TCOMPTE"; "48700000";
"MDEBITS"; [Total_MDEBITS];
"DCREDITS"; [Total_DCREDITS];
"TLIB"; SELECTEDVALUE(PCA[LIB2])
);
"CJOURNAL"; PCA[CJOURNAL];
"TCOMPTE"; "48700000";
"CSOC";'PCA'[SOCIETE];
"MDEBITS"; [Total_MDEBITS];
"DCREDITS"; [Total_DCREDITS];
"DECRIT"; PCA[DTECRIT];
"CANALYT3"; 'PCA'[ANALYT];
"TLIB"; SELECTEDVALUE(PCA[LIB2])
);
SELECTCOLUMNS(
FILTER(ALL('PCA'); LEFT('PCA'[TCOMPTE]; 1) = "7");
"CJOURNAL"; 'PCA'[CJOURNAL];
"TCOMPTE"; 'PCA'[TCOMPTE];
"CSOC"; 'PCA'[SOCIETE];
"MDEBITS"; 'PCA'[DEBITS];
"DCREDITS"; 'PCA'[CREDITS];
"DECRIT"; 'PCA'[DTECRIT];
"CANALYT3"; 'PCA'[ANALYT];
"TLIB"; 'PCA'[LIB2]
))
Thanks again for your helping !
Hi KevinSV - First, create a calculated column that identifies rows where TCOMPTE does not start with "7". This will help us distinguish the rows to aggregate.
IsAggregateRow =
IF(
LEFT('YourTable'[TCOMPTE], 1) <> "7",
1,
0
)
Now, create two measures to sum MDEBITS and DCREDITS for rows where TCOMPTE doesn’t start with "7" (i.e., where IsAggregateRow = 1). This will ensure that we get a single aggregated total for these values.
Total_MDEBITS =
CALCULATE(
SUM('YourTable'[MDEBITS]),
FILTER('YourTable', 'YourTable'[IsAggregateRow] = 1)
)
Total_DCREDITS =
CALCULATE(
SUM('YourTable'[DCREDITS]),
FILTER('YourTable', 'YourTable'[IsAggregateRow] = 1)
)
To combine the aggregated row with the original rows where TCOMPTE starts with "7", you can create a new table (using DAX) with the UNION function. This table will include one aggregated row and all individual rows with TCOMPTE starting with "7".
CombinedTable =
UNION(
SELECTCOLUMNS(
FILTER('YourTable', 'YourTable'[IsAggregateRow] = 1),
"CJOURNAL", "A", -- Replace "A" with your desired unique value
"TCOMPTE", "48700000",
"CSOC", SELECTEDVALUE('YourTable'[CSOC]),
"MDEBITS", [Total_MDEBITS],
"DCREDITS", [Total_DCREDITS],
"DECRIT", SELECTEDVALUE('YourTable'[DECRIT]),
"CANALYT3", SELECTEDVALUE('YourTable'[CANALYT3])
),
SELECTCOLUMNS(
FILTER('YourTable', LEFT('YourTable'[TCOMPTE], 1) = "7"),
"CJOURNAL", 'YourTable'[CJOURNAL],
"TCOMPTE", 'YourTable'[TCOMPTE],
"CSOC", 'YourTable'[CSOC],
"MDEBITS", 'YourTable'[MDEBITS],
"DCREDITS", 'YourTable'[DCREDITS],
"DECRIT", 'YourTable'[DECRIT],
"CANALYT3", 'YourTable'[CANALYT3]
)
)
In your report, use CombinedTable in a table visual to display the combined aggregated row and individual rows for TCOMPTE values that start with "7". This table should only contain the columns CJOURNAL, TCOMPTE, CSOC, MDEBITS, DCREDITS, DECRIT, and CANALYT3 as per your requirement.
Here is the update of the topic :
So i modify my code :
CombinedTable2 =
UNION(
SELECTCOLUMNS(
SUMMARIZE(
FILTER(ALL('PCA'); 'PCA'[IsAggregateRow] = 1);
'PCA'[SOCIETE]; PCA[CJOURNAL]; PCA[DTECRIT]; PCA[ANALYT]; --here is the modify i add all the column i need on this line of the code
"TCOMPTE"; "48700000";
"MDEBITS"; [Total_MDEBITS];
"DCREDITS"; [Total_DCREDITS];
"TLIB"; SELECTEDVALUE(PCA[LIB2])
);
"CJOURNAL"; PCA[CJOURNAL];
"TCOMPTE"; "48700000";
"CSOC";'PCA'[SOCIETE];
"MDEBITS"; [Total_MDEBITS];
"DCREDITS"; [Total_DCREDITS];
"DECRIT"; PCA[DTECRIT];
"CANALYT3"; 'PCA'[ANALYT];
"TLIB"; SELECTEDVALUE(PCA[LIB2])
);
SELECTCOLUMNS(
FILTER(ALL('PCA'); LEFT('PCA'[TCOMPTE]; 1) = "7");
"CJOURNAL"; 'PCA'[CJOURNAL];
"TCOMPTE"; 'PCA'[TCOMPTE];
"CSOC"; 'PCA'[SOCIETE];
"MDEBITS"; 'PCA'[DEBITS];
"DCREDITS"; 'PCA'[CREDITS];
"DECRIT"; 'PCA'[DTECRIT];
"CANALYT3"; 'PCA'[ANALYT];
"TLIB"; 'PCA'[LIB2]
))
Thanks again for your helping !