- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Add two or more columns with a condiotion
Hi,
I have the below data,
Column A | Column B | Column C |
ABC | Map | $56 |
EFG | Camera | $89 |
IJK | Electricity | $789 |
I want to do Sum (Column C, where Column A =ABC and Column B =Map) + Sum (Column C, where Column A =EFG and Column B =Camera) + Sum (Column C, where Column A =IJK and Column B =Electricity)
Can you tell me how to do in Power BI dax?
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @DryMouse555 ,
You can try out this DAX Measure,
TotalSum =
SUMX(
'YourTable',
SWITCH (
TRUE (),
'YourTable'[Column A] = "ABC" && 'YourTable'[Column B] = "Map", 'YourTable'[Column C],
'YourTable'[Column A] = "EFG" && 'YourTable'[Column B] = "Camera", 'YourTable'[Column C],
'YourTable'[Column A] = "IJK" && 'YourTable'[Column B] = "Electricity", 'YourTable'[Column C],
0 -- Default case, if none of the conditions match
)
)
or this one..
TotalSum =
SUMX(
FILTER(
'YourTable',
('YourTable'[Column A] = "ABC" && 'YourTable'[Column B] = "Map") ||
('YourTable'[Column A] = "EFG" && 'YourTable'[Column B] = "Camera") ||
('YourTable'[Column A] = "IJK" && 'YourTable'[Column B] = "Electricity")
),
'YourTable'[Column C]
)
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
A straightforward way if you have no much knowledge of DAX,
Sum1 =
CALCULATE(
SUM( DATA[Column C] ),
DATA[Column A] = "ABC" && DATA[Column B] = "Map"
|| DATA[Column A] = "EFG" && DATA[Column B] = "Camera"
|| DATA[Column A] = "IJK" && DATA[Column B] = "Electricity"
)
Another way in a more "DAX manner",
Sum2 =
CALCULATE(
SUM( DATA[Column C] ),
TREATAS(
{ ( "ABC", "Map" ), ( "EFG", "Camera" ), ( "IJK", "Electricity" ) },
DATA[Column A],
DATA[Column B]
)
)
Expertise = List.Accumulate( {Days as from Today}, {Skills and Knowledge}, (Current, Everyday) => Current & Day.LeanAndPractise(Everyday) ) |
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
A straightforward way if you have no much knowledge of DAX,
Sum1 =
CALCULATE(
SUM( DATA[Column C] ),
DATA[Column A] = "ABC" && DATA[Column B] = "Map"
|| DATA[Column A] = "EFG" && DATA[Column B] = "Camera"
|| DATA[Column A] = "IJK" && DATA[Column B] = "Electricity"
)
Another way in a more "DAX manner",
Sum2 =
CALCULATE(
SUM( DATA[Column C] ),
TREATAS(
{ ( "ABC", "Map" ), ( "EFG", "Camera" ), ( "IJK", "Electricity" ) },
DATA[Column A],
DATA[Column B]
)
)
Expertise = List.Accumulate( {Days as from Today}, {Skills and Knowledge}, (Current, Everyday) => Current & Day.LeanAndPractise(Everyday) ) |
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @DryMouse555 ,
You can try out this DAX Measure,
TotalSum =
SUMX(
'YourTable',
SWITCH (
TRUE (),
'YourTable'[Column A] = "ABC" && 'YourTable'[Column B] = "Map", 'YourTable'[Column C],
'YourTable'[Column A] = "EFG" && 'YourTable'[Column B] = "Camera", 'YourTable'[Column C],
'YourTable'[Column A] = "IJK" && 'YourTable'[Column B] = "Electricity", 'YourTable'[Column C],
0 -- Default case, if none of the conditions match
)
)
or this one..
TotalSum =
SUMX(
FILTER(
'YourTable',
('YourTable'[Column A] = "ABC" && 'YourTable'[Column B] = "Map") ||
('YourTable'[Column A] = "EFG" && 'YourTable'[Column B] = "Camera") ||
('YourTable'[Column A] = "IJK" && 'YourTable'[Column B] = "Electricity")
),
'YourTable'[Column C]
)
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
Helpful resources
Join us at the Microsoft Fabric Community Conference
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Microsoft Fabric Community Conference 2025
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
Subject | Author | Posted | |
---|---|---|---|
08-21-2024 06:40 AM | |||
05-18-2024 05:37 PM | |||
06-19-2024 07:55 AM | |||
01-18-2024 11:10 PM | |||
01-11-2024 07:16 AM |
User | Count |
---|---|
21 | |
18 | |
17 | |
7 | |
5 |
User | Count |
---|---|
32 | |
27 | |
19 | |
13 | |
12 |