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
Anonymous
Not applicable

Parameter and measure that will subtract values from the previous one - Power BI Desktop

Hi All,

I need to calculate the difference between consecutive values between the "Budget" parameter and the "B" column.

It should look like that each time we subtract the value from the "B" column from the budget, which has been reduced by the value of all its predecessors.

A, B - available in the form of a column and a metric
Budget - parameter (separate table created by Power BI)

 

Example (period 1):
Budget = 6 230 000
B = 1 617 432
Result = 6 230 000 - 1 617 432 = 4 612 568

Example (period 2):
Budget = 6 230 000 - 1 617 432 = 4 612 568
B = 702 897
Result = 4 612 568 - 702 897 = 3 909 671

Current result: I managed to achieve this effect by using single metrics and overlapping 12 individual cards (which is not professional and does not allow exporting the entire table to Excel).

 

Expected result: each time the budget should be reduced by the value from column "B".

 

Does anyone have an idea how to implement this? Perhaps using variables that would store such information.

Thank you!

Power BI - screen.png

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

Hi, @Anonymous 

According to your description, you want to "Parameter and measure that will subtract values from the previous one".

Here are the steps you can refer to :
(1)This is my test data:

vyueyunzhmsft_0-1675647034829.png

(2)I create a [B] measure as your B column in the visual :

B = SUM('Table'[Value])

(3)Then we can create a measre like this :

Measure = var _slicer = [Parameter Value]
var _cur_date = MAX('Table'[Date]) 
var _t=  FILTER( ALLSELECTED('Table') , 'Table'[Date] <= _cur_date) 
return
_slicer  -  SUMX(_t, [B]) 

(4)Then we can put the measure on the visual and we can meet your need :

vyueyunzhmsft_1-1675647102807.png

 

 

If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem.

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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

3 REPLIES 3
v-yueyunzh-msft
Community Support
Community Support

Hi, @Anonymous 

According to your description, you want to "Parameter and measure that will subtract values from the previous one".

Here are the steps you can refer to :
(1)This is my test data:

vyueyunzhmsft_0-1675647034829.png

(2)I create a [B] measure as your B column in the visual :

B = SUM('Table'[Value])

(3)Then we can create a measre like this :

Measure = var _slicer = [Parameter Value]
var _cur_date = MAX('Table'[Date]) 
var _t=  FILTER( ALLSELECTED('Table') , 'Table'[Date] <= _cur_date) 
return
_slicer  -  SUMX(_t, [B]) 

(4)Then we can put the measure on the visual and we can meet your need :

vyueyunzhmsft_1-1675647102807.png

 

 

If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem.

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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

 

Anonymous
Not applicable

Hi v-yueyunzh-msft!

It works! Thank you very much for help.
I really appreciate it!
All the best to you!

Ahmedx
Super User
Super User

Share sample pbix file to help you

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.