We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now
Hello everyone,
Im kinda new to the DAX and im struggleing to calculate the final cost price of a product based on some variables.
What i have fixed is following:
The requirement is: if there is no value in the column Ending Date (see image below) then use the variable FinalCostPriceWithoutDate , otherwise use the variable FinalCostPriceWithDate .
My question is how to return the correct value (based on the underneath Dax) if there is no data in a column Ending Date (see image below) I think the part of Var NoDate and my Return statement is not correct. Please help.
Kind regards
Totaal CostPrice Products =
VAR Date =
MAX ( Fact_ValueEntry[PostingDate] )
VAR NoDate =
MIN (Dim_PurchasePrice[EndingDate])
VAR Product =
MAX ( Fact_ValueEntry[ItemFK] )
VAR CostPriceWithDate =
CALCULATE (
MAX ( Dim_PurchasePrice[DirectUnitCost] ),
Dim_PurchasePrice[ItemFK] = Product,
Dim_PurchasePrice[StartingDate] < Date,
Dim_PurchasePrice[EndingDate] >= Date
)
VAR CostPriceWithoutDate =
CALCULATE (
MAX ( Dim_PurchasePrice[DirectUnitCost] ),
Dim_PurchasePrice[ItemFK] = Product,
Dim_PurchasePrice[StartingDate] < Date,
Dim_PurchasePrice[EndingDate] = NoDate)
VAR CostPriceInk =
CALCULATE (
max ( Dim_PurchasePrice[DirectUnitCost] ),
Dim_PurchasePrice[ItemFK] = "INK")
VAR CostPriceGlue =
CALCULATE (
max ( Dim_PurchasePrice[DirectUnitCost] ),
Dim_PurchasePrice[ItemFK] = "GLUE")
VAR FinalCostPriceWithDate = CostPriceWithDate + CostPriceInk + CostPriceGlue
VAR FinalCostPriceWithoutDate = CostPriceWithoutDate + CostPriceInk + CostPriceGlue
RETURN
IF(ISBLANK(NoDate), FinalCostPriceWithoutDate, FinalCostPriceWithDate))
Solved! Go to Solution.
Hi @rsanyoto ,
Very happy about your feedback.
If the problem has been solved, you can mark the correct response as the standard answer to help the other members find it more quickly. Looking forward to your reply.
Best Regards,
Henry
Can you provide a test pbix please because it's a bit difficult to debug this without seeing the model/relationships?
Just fake a small example (and provide the desired result please) and link it from an external site and I'll have a look for you
Hi @HotChilli ,
I have uploaded the pbix example in my public github repository. Download the file of 2,19 mb
Please try this link:
https://github.com/regazzi24/powerbi/blob/main/Example%2011102021%20v1.pbix
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 57 | |
| 38 | |
| 33 | |
| 19 | |
| 16 |
| User | Count |
|---|---|
| 68 | |
| 66 | |
| 41 | |
| 34 | |
| 25 |