Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hi!
I'm having trouble with writing this DAX command. I'm trying to change a value based on the value in another column. For example, I attached an example power bi file and a picture of the chart.
For each transaction type, a number is assigned in a Status column, for Deaths,Dropped and Resignations its -1 and for Elected and Reinstated its 1.
I'm trying to have a total that includes everyone including the people who died (without counting the same person twice). I also have to show a breakdown of this number in a chart that is seperated by transaction.
I was wondering if there was a way for me to have this count but if a person who was previously elected and is now dead, if there was a way for me to switch the value in the Status column for them being elected to -1 (instead of 1) and death to 1 (instead of -1)
https://drive.google.com/file/d/1eW3S5ZDKbShKp8wYvwYJZXUyo4oY91FM/view?usp=sharing
Thank you for your help!!! Let me know if you have questions!
Solved! Go to Solution.
Hi,
Please check the below measure.
new total: =
VAR currenttransaction =
MAX ( data[Transaction] )
VAR electedlist =
SUMMARIZE (
FILTER (
SUMMARIZE ( ALL ( data ), data[name], data[date], data[Transaction] ),
data[Transaction] = "Elected"
),
data[name]
)
VAR deathslist =
SUMMARIZE (
FILTER (
SUMMARIZE ( ALL ( data ), data[name], data[date], data[Transaction] ),
data[Transaction] = "Deaths"
),
data[name]
)
VAR bothlist =
INTERSECT ( electedlist, deathslist )
VAR currentalltable =
SUMMARIZE ( ALL ( data ), data[name], data[Transaction], data[Status] )
VAR exceptbothlistname =
FILTER (
SUMMARIZE ( ALL ( data ), data[name], data[Transaction], data[Status] ),
NOT ( data[name] IN bothlist )
)
RETURN
SUMX (
FILTER ( exceptbothlistname, data[Transaction] = currenttransaction ),
data[Status]
)
+ SUMX ( FILTER ( data, data[name] IN bothlist ), data[Status] * -1 )
If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.
Hi,
Please check the below measure.
new total: =
VAR currenttransaction =
MAX ( data[Transaction] )
VAR electedlist =
SUMMARIZE (
FILTER (
SUMMARIZE ( ALL ( data ), data[name], data[date], data[Transaction] ),
data[Transaction] = "Elected"
),
data[name]
)
VAR deathslist =
SUMMARIZE (
FILTER (
SUMMARIZE ( ALL ( data ), data[name], data[date], data[Transaction] ),
data[Transaction] = "Deaths"
),
data[name]
)
VAR bothlist =
INTERSECT ( electedlist, deathslist )
VAR currentalltable =
SUMMARIZE ( ALL ( data ), data[name], data[Transaction], data[Status] )
VAR exceptbothlistname =
FILTER (
SUMMARIZE ( ALL ( data ), data[name], data[Transaction], data[Status] ),
NOT ( data[name] IN bothlist )
)
RETURN
SUMX (
FILTER ( exceptbothlistname, data[Transaction] = currenttransaction ),
data[Status]
)
+ SUMX ( FILTER ( data, data[name] IN bothlist ), data[Status] * -1 )
If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.
Thank you!!
I was wondering how I would factor in the other transaction types like resignations and reinstatements. Also, I was wondering if there was a way for me to get the first transaction type of a person. Would I do Min(data[Transaction])?
Hi,
Thank you for your feedback.
I think you can use the similar way to identify the type.
And in a general situation, MIN function is used to get the first date of the transaction.
Thanks.
If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
18 | |
15 | |
11 | |
11 | |
8 |
User | Count |
---|---|
24 | |
18 | |
12 | |
11 | |
10 |