Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
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:]
)
)
)
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:]
)
)
)
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 14 | |
| 7 | |
| 4 | |
| 4 | |
| 3 |
| User | Count |
|---|---|
| 25 | |
| 10 | |
| 10 | |
| 6 | |
| 6 |