Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Dear All,
I need your help for my below need. Here the explanations :
To make it simpler, let's say I have 1 fact table called "PROJECTION" in which I project the stock of my components. In the attached picture I only have 2 components A & B.
Every month I take "a picture" of this data in my ERP and thanks to Query I combine all pictures in the PROJECTION table.
The column "PICTURE DATE" is the month I have extracted the data (here only OCT24 & NOV24). In each picture, we project for each item a quantity available and a quantity blocked AND for each end of coming months (that are in column "PROJECTION DATE").
I already created a DAX measure called "TOTAL QTY" as per :
Solved! Go to Solution.
hi @yoa380 ,
try like:
V_TOTAL QTY_NEW =
VAR selectedpicture = SELECTEDVALUE(SELECT_PIC[ShortDate])
RETURN
IF(
YEAR(PROJECTION DATE) <= YEAR(TODAY()),
CALCULATE(
SUMX(
PROJECTION,
PROJECTION[TOTAL QTY]*PROJECTION[COST_WAC]
),
PROJECTION[PICTURE DATE]=selectedpicture
),
CALCULATE(
SUMX(
PROJECTION,
PROJECTION[TOTAL QTY]*RELATED(BUD[COST_BUD]
),
PROJECTION[PICTURE DATE]=selectedpicture
)
)
Hi @yoa380 ,
Can you please use this and check does it works in the scenario you mentioned.
DAX:
V_TOTAL QTY_NEW =
VAR selectedpicture = SELECTEDVALUE(SELECT_PIC[ShortDate])
RETURN
CALCULATE(
SUMX(
PROJECTION,
PROJECTION[TOTAL QTY] *
IF(
YEAR(PROJECTION[PROJECTION DATE]) <= YEAR(TODAY()),
RELATED(WAC[COST]), -- Use WAC cost if projection date is in the current year or earlier
RELATED(BUD[COST]) -- Use BUD cost if projection date is in the future
)
),
PROJECTION[PICTURE DATE] = selectedpicture
)
This measure (V_TOTAL QTY_NEW) will dynamically adjust based on the year of PROJECTION DATE and multiply TOTAL QTY by either WAC or BUD cost as specified.
Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂
Kind Regards,
Poojara.
Data Analyst | MSBI Developer | Power BI Consultant
Hi @yoa380 ,
Can you please use this and check does it works in the scenario you mentioned.
DAX:
V_TOTAL QTY_NEW =
VAR selectedpicture = SELECTEDVALUE(SELECT_PIC[ShortDate])
RETURN
CALCULATE(
SUMX(
PROJECTION,
PROJECTION[TOTAL QTY] *
IF(
YEAR(PROJECTION[PROJECTION DATE]) <= YEAR(TODAY()),
RELATED(WAC[COST]), -- Use WAC cost if projection date is in the current year or earlier
RELATED(BUD[COST]) -- Use BUD cost if projection date is in the future
)
),
PROJECTION[PICTURE DATE] = selectedpicture
)
This measure (V_TOTAL QTY_NEW) will dynamically adjust based on the year of PROJECTION DATE and multiply TOTAL QTY by either WAC or BUD cost as specified.
Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂
Kind Regards,
Poojara.
Data Analyst | MSBI Developer | Power BI Consultant
I think I found the solution, hope it will be stable ....
I use filters of calculate and do +
V_TOTAL QTY_NEW =
VAR selectedpicture = SELECTEDVALUE(SELECT_PIC[ShortDate])
RETURN
CALCULATE(
SUMX(PROJECTION, PROJECTION[TOTAL QTY]*PROJECTION[COST_WAC]), PROJECTION[PICTURE DATE]=selectedpicture, YEAR(PROJECTION DATE)<=YEAR(TODAY())) +
SUMX(PROJECTION, PROJECTION[TOTAL QTY]*PROJECTION[COST_BUD]), PROJECTION[PICTURE DATE]=selectedpicture, YEAR(PROJECTION DATE)>YEAR(TODAY()))
Hello, thanks for quick reply. I cannot do that, first when I type IF( YEAR( ... it doesn't offer the choice to put PROJECTION DATE. It only shows measures from the table, not the other simple columns.
And if I force the formula with it, it will tell me : impossible to determine a unique value for the "projection date" column in the table. This can happen when a measurement formula refers to a column that contains many values, without specifying an aggregation such as min, max, count or sum to get a unique result.
hi @yoa380 ,
try like:
V_TOTAL QTY_NEW =
VAR selectedpicture = SELECTEDVALUE(SELECT_PIC[ShortDate])
RETURN
IF(
YEAR(PROJECTION DATE) <= YEAR(TODAY()),
CALCULATE(
SUMX(
PROJECTION,
PROJECTION[TOTAL QTY]*PROJECTION[COST_WAC]
),
PROJECTION[PICTURE DATE]=selectedpicture
),
CALCULATE(
SUMX(
PROJECTION,
PROJECTION[TOTAL QTY]*RELATED(BUD[COST_BUD]
),
PROJECTION[PICTURE DATE]=selectedpicture
)
)
Yes, it seems to work thanks ! same result as my previous addition but shorter DAX
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
23 | |
7 | |
7 | |
6 | |
6 |
User | Count |
---|---|
27 | |
12 | |
10 | |
9 | |
6 |