Forum Discussion
Sum With Multiple filters
Hello Everyone,
I'm newbie in power BI environment and I don't find the answer to my question in all topics I found, I hope I didn't miss one!
I have several tables witch are gathering all my data of turnover per month. each table are named 2017_01_turnover, 2017_02_turnover, 2017_03....
I want to calculate the results of my full turnover for the whole year with several filters.
[Code_Client] : is the column of my customers' key which I want to allocate the turnover
Reseau : The tab where I want to gather result per Customer
Reseau[DC_X]: is one of the buyer's key allocated to customer
2017_01_Turnover'[DC_1]: The key allocated for each sell
I want to sum the turnover of each customer, which have the same buyer key (among the 6 they have) than each sell which are in turnover tables.
to sumup : =Client_Code && Reseau[DC] = '2017_01_Turnover'[DC_1]
Here the first code I created only for the first tab (2017_01_turnover, there is 11 others tab):
Ca_Net_01 =
CALCULATE (
SUM ( '2017_01_Turnover'[CA_Net]);
FILTER (
'2017_01_Turnover';
'2017_01_Turnover'[Code_Client] =Reseau[Code_client]
&&Reseau[DC_1]='2017_01_Turnover'[DC_1]
|| Reseau[DC_2]='2017_01_Turnover'[DC_1]
|| Reseau[DC_3]='2017_01_Turnover'[DC_1]
|| Reseau[DC_4]='2017_01_Turnover'[DC_1]
|| Reseau[DC_5]='2017_01_Turnover'[DC_1]
|| Reseau[DC_6]='2017_01_Turnover'[DC_1]
)
)I hope it's clear.
Thanks a lot!
3 Replies
- v-yulgu-msftMicrosoft Employee
- GeoffreyFrequent Visitor
I want to calculate per Code_Client the total of sales, but only sales of Code_client associate to Digit Code (DC_X, each Code_client can have until 31 Digit code)
Dictionare
Code_client DC_1 DC_2 DC_3 DC_4 DC_5 DC_6 DC_7 DC_8 DC_9 1 C 1 3 4 7 Y D K P 2 T W M H E X 9 5 3 4 S W P 9 8 7 5 S W P 9 8 7 6 S W P 9 8 7 3 S W P 9 8 7 10 S W P 9 8 7 11 S W P 9 8 7 1520 S W P 9 8 7 656152 S W P 9 8 7 654564 S W P 9 8 7 6236 S W P 9 8 7 36546 2 W M H E X 9 5 3 Verbatim
Code_Client Price DC_1 11 13,55 9 3 4,35 8 6554 6,35 7 61 117,28 S 11 10,79 W 11 52,42 X 2544 57,91 Z 6545 18,06 0 151 98,8 1 15 203,84 C What I am expecting are results like:
Code_client Total 1 155,2 2 245,7 1520 10,54 656152 80,96 654564 2546,78 6236 758,6 36546 7548,55 I hope, it's better like this
Here my current code :
Ca_Net_01 = CALCULATE ( SUM ( '2017_01_Turnover'[CA_Net]); FILTER ( '2017_01_Turnover'; and('2017_01_Turnover'[Code_Client] = Reseau[Code_client] ; Reseau_DC[Code_Client] = Reseau[Code_client]) && ( Reseau_DC[DC_1]='2017_01_Turnover'[DC_1] || Reseau_DC[DC_2]='2017_01_Turnover'[DC_1] || Reseau_DC[DC_3]='2017_01_Turnover'[DC_1] || Reseau_DC[DC_4]='2017_01_Turnover'[DC_1] || Reseau_DC[DC_5]='2017_01_Turnover'[DC_1] || Reseau_DC[DC_6]='2017_01_Turnover'[DC_1] || Reseau_DC[DC_7]='2017_01_Turnover'[DC_1] || Reseau_DC[DC_8]='2017_01_Turnover'[DC_1] || Reseau_DC[DC_9]='2017_01_Turnover'[DC_1] || Reseau_DC[DC_10]='2017_01_Turnover'[DC_1] || Reseau_DC[DC_11]='2017_01_Turnover'[DC_1] || Reseau_DC[DC_12]='2017_01_Turnover'[DC_1] || Reseau_DC[DC_13]='2017_01_Turnover'[DC_1] || Reseau_DC[DC_13]='2017_01_Turnover'[DC_1] || Reseau_DC[DC_15]='2017_01_Turnover'[DC_1] || Reseau_DC[DC_16]='2017_01_Turnover'[DC_1] || Reseau_DC[DC_17]='2017_01_Turnover'[DC_1] || Reseau_DC[DC_18]='2017_01_Turnover'[DC_1] || Reseau_DC[DC_19]='2017_01_Turnover'[DC_1] || Reseau_DC[DC_20]='2017_01_Turnover'[DC_1] || Reseau_DC[DC_21]='2017_01_Turnover'[DC_1] || Reseau_DC[DC_22]='2017_01_Turnover'[DC_1] || Reseau_DC[DC_23]='2017_01_Turnover'[DC_1] || Reseau_DC[DC_24]='2017_01_Turnover'[DC_1] || Reseau_DC[DC_25]='2017_01_Turnover'[DC_1] || Reseau_DC[DC_26]='2017_01_Turnover'[DC_1] || Reseau_DC[DC_27]='2017_01_Turnover'[DC_1] || Reseau_DC[DC_28]='2017_01_Turnover'[DC_1] || Reseau_DC[DC_29]='2017_01_Turnover'[DC_1] || Reseau_DC[DC_30]='2017_01_Turnover'[DC_1] || Reseau_DC[DC_31]='2017_01_Turnover'[DC_1] ) ) )Cheers,
- v-yulgu-msftMicrosoft Employee
Hi Geoffrey,
Still have some concern:
- Are '2017_01_Turnover' and 'Reseau' represent Dictionare and Verbatim in your provided sample data?
- But where is field '2017_01_Turnover'[CA_Net]? And what is table 'Reseau_DC'?
- In above expected result table, how to calculate the value of Total? Please illustrate with examples?
- I still cannot understand the intention of above DAX formula.
One suggestion you can have a try is unpivoting 'Dictionare' table first.
Regards,
Yuliana Gu