cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sridharpolina
Helper I
Helper I

Calculating delta of product Quantity between two dynamically selected dates

I am trying to calculate the delta of product quantity for two dynamically selected dates. I have a table populating the beginning, ending and the delta inventory for both the dates. Now I am having trouble calculating the delta between DI2-DI1 as shown in the image. The date selection is dynamic and User selected. The sample data and the .pbix files are uploaded to Goggle Drive. Any help is appreciated.

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

Hi @sridharpolina ,

 

Here are the steps you can follow:

1. Create calculated table.

Table = SUMMARIZE('Inventory Changes','Inventory Changes'[as_of_date])

Result:

v-yangliu-msft_0-1619415286552.png

2. Replace the second slicer with [as_of_date] of the newly created table

v-yangliu-msft_1-1619415286558.png

3. Select the slicer above, select Edit interactions of Format, and select the Filter flags in both tables

v-yangliu-msft_2-1619415286564.png

4. Create measure.

_begin = 
SUMX(FILTER(ALL('Inventory Changes'),[as_of_date] in SELECTCOLUMNS('Table',"1",[as_of_date])&&[product_identifier1]=MAX([product_identifier1])),[opening_inv])
_end = 
SUMX(FILTER(ALL('Inventory Changes'),[as_of_date] in SELECTCOLUMNS('Table',"1",[as_of_date])&&[product_identifier1]=MAX([product_identifier1])),[closing_inv])
Delta_Inventory1 =
[_end]-[_begin]
Delta_Inventory2 =
SUM('Inventory Changes'[Delta_Inventory])-[Delta_Inventory1]

5. Result.

123.png

 

 

 Best Regards,

Liu Yang

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

1 REPLY 1
v-yangliu-msft
Community Support
Community Support

Hi @sridharpolina ,

 

Here are the steps you can follow:

1. Create calculated table.

Table = SUMMARIZE('Inventory Changes','Inventory Changes'[as_of_date])

Result:

v-yangliu-msft_0-1619415286552.png

2. Replace the second slicer with [as_of_date] of the newly created table

v-yangliu-msft_1-1619415286558.png

3. Select the slicer above, select Edit interactions of Format, and select the Filter flags in both tables

v-yangliu-msft_2-1619415286564.png

4. Create measure.

_begin = 
SUMX(FILTER(ALL('Inventory Changes'),[as_of_date] in SELECTCOLUMNS('Table',"1",[as_of_date])&&[product_identifier1]=MAX([product_identifier1])),[opening_inv])
_end = 
SUMX(FILTER(ALL('Inventory Changes'),[as_of_date] in SELECTCOLUMNS('Table',"1",[as_of_date])&&[product_identifier1]=MAX([product_identifier1])),[closing_inv])
Delta_Inventory1 =
[_end]-[_begin]
Delta_Inventory2 =
SUM('Inventory Changes'[Delta_Inventory])-[Delta_Inventory1]

5. Result.

123.png

 

 

 Best Regards,

Liu Yang

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

Helpful resources

Announcements
September Update

Check it Out!

Click here to learn more about the September 2022 updates!

Power BI Show episode 9

The Power BI Community Show

Watch the playback when Priya Sathy and Charles Webb discuss Datamarts! Kelly also shares Power BI Community updates.

Power BI Dev Camp Session 26

New Date - Check it Out!

Mark your calendars and join us on Thursday, October 6 at 11a PDT for a great session with Ted Pattison!

Top Solution Authors