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.
Hello - I need to create a measure as
If trans_status is Sales return 1 and If trans_status is Refund return -1 else 0.
Table
trans_status |
Sales |
Sales |
Sales |
Refund |
Sales |
Refund |
Solved! Go to Solution.
Hi,
I assume the table contains more than one column, and I tried to create a sample pbix file like below.
Please check the below picture and the attached pbix file.
expected result measure: =
VAR _condition =
HASONEVALUE ( 'Table'[trans_status] )
VAR _resultcondition =
DIVIDE ( _condition, _condition )
RETURN
_resultcondition
* SWITCH ( SELECTEDVALUE ( 'Table'[trans_status] ), "Sales", 1, "Refund", -1, 0 )
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.
Yes, there was an issue in Refund section, rather than " i typed ).
Fixed here:
WITHOUT Total:
Measure=
IF (
HASONEVALUE ( 'Table'[trans_status] ),
SWITCH ( MAX ( 'Table'[trans_status] ), "Sales", 1, "Refund", -1, 0 )
)
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Try this measure:
Measure =
SWITCH (MAX( 'Table'[trans_status]),
"Sales",1,
"Refund",-1,
0
)
if you want to show nothing in total section if using this measure:
Measure =
IF (
HASONEVALUE ( 'Table'[trans_status] ),
SWITCH (MAX( 'Table'[trans_status]),
"Sales",1,
"Refund",-1,
0
)
)
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
@VahidDM - These measure are not returning any result. Looking like something is missing.
Yes, there was an issue in Refund section, rather than " i typed ).
Fixed here:
WITHOUT Total:
Measure=
IF (
HASONEVALUE ( 'Table'[trans_status] ),
SWITCH ( MAX ( 'Table'[trans_status] ), "Sales", 1, "Refund", -1, 0 )
)
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Hi,
I assume the table contains more than one column, and I tried to create a sample pbix file like below.
Please check the below picture and the attached pbix file.
expected result measure: =
VAR _condition =
HASONEVALUE ( 'Table'[trans_status] )
VAR _resultcondition =
DIVIDE ( _condition, _condition )
RETURN
_resultcondition
* SWITCH ( SELECTEDVALUE ( 'Table'[trans_status] ), "Sales", 1, "Refund", -1, 0 )
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.
User | Count |
---|---|
117 | |
73 | |
58 | |
49 | |
48 |
User | Count |
---|---|
171 | |
122 | |
60 | |
59 | |
56 |