Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowGet inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.
I have a table / matrix with the following structure:
Year-Week | WeekIndex | Inventory | Planned Sales | Sales | Inventory Planned |
2024-01 | -1 | 5 | 1 | 2 | 5 |
2024-02 | 0 | 4 | 2 | 1 | 4 |
2024-03 | 1 | 2 | 3 | ||
2024-04 | 2 | 0 | 3 |
I would like to create the last column based on the following filters:
How would you do that with a DAX measure?
Solved! Go to Solution.
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.
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.
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:
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
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:
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
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.
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.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!
Check out the February 2025 Power BI update to learn about new features.
User | Count |
---|---|
21 | |
12 | |
10 | |
9 | |
9 |
User | Count |
---|---|
17 | |
14 | |
12 | |
9 | |
9 |