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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

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.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

View solution in original post

v-yangliu-msft
Community Support
Community Support

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
v-yangliu-msft
Community Support
Community Support

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.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

March2025 Carousel

Fabric Community Update - March 2025

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