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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
joshua1990
Post Prodigy
Post Prodigy

Combine actual sales with planned sales with inventory

I have a table / matrix with the following structure:

Year-WeekWeekIndexInventoryPlanned SalesSalesInventory Planned
2024-01-15125
2024-0204214
2024-031 2 3
2024-042 0 3

 

I would like to create the last column based on the following filters:

  • If WeekIndex <=0 then take the actual Inventory from column 3
  • If WeekIndex >0 then substract the Inventory by the planned Sales

 

How would you do that with a DAX measure?

 

2 ACCEPTED SOLUTIONS
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your semantic model looks like, but I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file.

 

Jihwan_Kim_0-1730779177571.png

 

 

Expected result measure: =
SUMX (
    VALUES ( Data[Year-Week] ),
    CALCULATE (
        SWITCH (
            TRUE (),
            SELECTEDVALUE ( Data[WeekIndex] ) <= 0, [Inventory measure:],
            SELECTEDVALUE ( Data[WeekIndex] ) > 0, [Inventory measure:] - [Planned Sales measure:]
        )
    )
)

 


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

Anonymous
Not applicable

Thanks for the reply from Jihwan_Kim , please allow me to provide another insight: 
Hi  @joshua1990 ,

 

Here are the steps you can follow:

1. Create calculated column.

Column =
IF(
    'Table'[WeekIndex]>0,
    SUMX(
    FILTER(ALL('Table'),[WeekIndex]>0),[Inventory] - [Planned Sales]),
    SUMX(
    FILTER(ALL('Table'),[WeekIndex]<=0),[Inventory])
)

2. Result:

vyangliumsft_0-1730881122773.png

If the above results do not meet your expectations, you can express the expected results in the form of a picture, we can better help you!

 

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

2 REPLIES 2
Anonymous
Not applicable

Thanks for the reply from Jihwan_Kim , please allow me to provide another insight: 
Hi  @joshua1990 ,

 

Here are the steps you can follow:

1. Create calculated column.

Column =
IF(
    'Table'[WeekIndex]>0,
    SUMX(
    FILTER(ALL('Table'),[WeekIndex]>0),[Inventory] - [Planned Sales]),
    SUMX(
    FILTER(ALL('Table'),[WeekIndex]<=0),[Inventory])
)

2. Result:

vyangliumsft_0-1730881122773.png

If the above results do not meet your expectations, you can express the expected results in the form of a picture, we can better help you!

 

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

Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your semantic model looks like, but I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file.

 

Jihwan_Kim_0-1730779177571.png

 

 

Expected result measure: =
SUMX (
    VALUES ( Data[Year-Week] ),
    CALCULATE (
        SWITCH (
            TRUE (),
            SELECTEDVALUE ( Data[WeekIndex] ) <= 0, [Inventory measure:],
            SELECTEDVALUE ( Data[WeekIndex] ) > 0, [Inventory measure:] - [Planned Sales measure:]
        )
    )
)

 


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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.

Users online (3,142)