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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
AllanBerces
Post Partisan
Post Partisan

Difference Value

Hi folks,

How can I have an output on the table below using measure. Basically
if available is 0 the output is equal to Required,
if available is equal to required the output is 0,
if avaialable is greater than required the output is 0,  

if available is less than required subtract required to avialable (required - Available = diff (output)

 

AllanBerces_0-1709465025011.png

Thank you

1 ACCEPTED SOLUTION
v-jiewu-msft
Community Support
Community Support

Hi @AllanBerces ,

Please try the following methods and check if they can solve your problem:

1.Create the simple table.

vjiewumsft_0-1709617313293.png

2.Create the new measure to filter.

 

Output Measure = 
VAR Available = SELECTEDVALUE('Table'[Available]) 
VAR Required = SELECTEDVALUE('Table'[Required])   
RETURN
    IF(
        Available = 0,
        Required,
        IF(
            Available = Required,
            0, 
            IF(
                Available > Required,  
                0,
                Required - Available
            )
        )
    )

 

 

3.Drag the measure into the card visual. The result is shown below.

vjiewumsft_1-1709617349357.png

 

Best Regards,

Wisdom Wu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

 

View solution in original post

4 REPLIES 4
v-jiewu-msft
Community Support
Community Support

Hi @AllanBerces ,

Please try the following methods and check if they can solve your problem:

1.Create the simple table.

vjiewumsft_0-1709617313293.png

2.Create the new measure to filter.

 

Output Measure = 
VAR Available = SELECTEDVALUE('Table'[Available]) 
VAR Required = SELECTEDVALUE('Table'[Required])   
RETURN
    IF(
        Available = 0,
        Required,
        IF(
            Available = Required,
            0, 
            IF(
                Available > Required,  
                0,
                Required - Available
            )
        )
    )

 

 

3.Drag the measure into the card visual. The result is shown below.

vjiewumsft_1-1709617349357.png

 

Best Regards,

Wisdom Wu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

 

Hi @v-jiewu-msft 

Thank you very much, working perfectly.

AllanBerces
Post Partisan
Post Partisan

By the way Required and Available i used measure.

 

thank you

@AllanBerces 

\use the following pattern for the dax code :

 

measure = 



var ds_add = 

addcolumns(

addcolumns ( 

values(tbl_name[col_name] ) //  col_name = column ID , which contains the values :  aaa, ccc,rrr ....

"requied" , [ required_measure], 

"available", [available_measure] 

), 

"output", 

switch(

true(), 

[available] = 0 ,  [required],

[available]= [required] , 0 , 

[available] > [required] , 0 , 

[available] < [required] , [required] - [available]

)
)





var res= 

maxx( ds_add , [output] ) 



return res

 

let me know if this helps .

 

 

 

If my answer helped sort things out for you, i would appreciate a thumbs up 👍 and mark it as the solution
It makes a difference and might help someone else too. Thanks for spreading the good vibes! 🤠

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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