Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
InsightSeeker
Helper III
Helper III

Need help with measure

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
2 ACCEPTED SOLUTIONS
Jihwan_Kim
Super User
Super User

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.

 

Jihwan_Kim_0-1717920395865.png

 

 

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.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

@InsightSeeker 

 

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!! 

LinkedIn | Twitter | Blog | YouTube 

View solution in original post

4 REPLIES 4
VahidDM
Super User
Super User

Hi @InsightSeeker 

 

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!! 

LinkedIn | Twitter | Blog | YouTube 

@VahidDM - These measure are not returning any result. Looking like something is missing.

@InsightSeeker 

 

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!! 

LinkedIn | Twitter | Blog | YouTube 

Jihwan_Kim
Super User
Super User

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.

 

Jihwan_Kim_0-1717920395865.png

 

 

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.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors