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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Nicki
Helper III
Helper III

how to create a column to subtract a measure from a column

I have a column in  [table A] that has the value of Duration and it is integer. 

The value of slicer is calcuated  as a measure:

        Measureslicer = VALUE(MAX(tableB[DURATION])) 

Then,  I need to have a column for my chart.

new column= if (TableA[Duration] - Measureslicer >1 ,1,0)

It does not work  and shows 0 for all rows.

For example, when Duration  is  3  and Measureslicer  is  11 ,

If I assign Measureslicer to a  column  and it will be 30840 instead of 11 but I can see the correct value of measure "11" as a measure. because of this reason subtract and if statement does not work.  

In fact, the value of measure is not correct when assign to a column or  doing subtract.

 

Thank you in advance for help.

6 REPLIES 6
ccakjcrx
Resolver I
Resolver I

Hey @Nicki!

 

You reference two tables in your post. Do you have two tables, or one? If you have one table, the if statement is working correctly.

 

The measure returns the maximum value from the column.

 

The if statement then subtracts the maximum value (generated from the measure) from each value in the duration column; this won't produce a value greater than 1. Given the if statement is set up to return 0 if duration - max duration < 1, you should get a zero in each row under your new calculated column.

Thanks.

How can I use the selected value of slicer?

In this case, I do not need to put the max(duration) from slicer.

the slicer is  "less than or equal to"  and I need the second value.

 

MDuration is a measure in [DurationTable] that includes the selected value of  the slicer.  For example for duration= 100  , new column must be 1 but it is zero. 

I can show in an image and It does not work,image1.JPG

did you used the DAX I provided.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Yes.

parry2k
Super User
Super User

new column =
var myMeasure = [measureslicer]
return if(Table[Duration] - myMeasure > 1, 1, 0)


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.