Scenario:
Suppose we have a Data Model as shown below.
Suppose we have a Data Model as shown below.
The fact_Target table having the Target data defined at Product and Customer level only for the Year 2022, as shown in below sample.
Net Sales = SUM(fact_Sales[Net Sales])
Sales Target = SUM(fact_Target[Target Value])
We can achieve this Scenario using the following DAX Measure logics:
We can calculate the Target to show only for the available Target Year using below Logics:
Sales with Target =
CALCULATE (
[Net Sales],
SUMMARIZE(
fact_Target,
/* Brige_Year[Year],*/
dim_Product[ProductKey],
dim_Customer[CustomerKey]
)
)
Sales with Target Flag =
AND( NOT ISBLANK([Sales Target]), NOT ISBLANK([Sales with Target]))*1
Actual Target Year Flag =
VAR _TargetByYear =
CALCULATE(DISTINCTCOUNT(fact_Target[ProductKey]), dim_Date)
VAR _Target_Flag = IF(_TargetByYear>0,1,0)
RETURN
_Target_Flag
Actual Target =
CALCULATE (
[Sales Target],
FILTER( VALUES(fact_Target[ProductKey]),
[Actual Target Year Flag]=1
))
Result:
[Sales Year] is considered from dim_Date[Year]
[Outlet Name] is considered from dim_Customer
[Brand Name] is considered from dim_Product
[Product SKUs] is considered form dim_Product
No comments:
Post a Comment
Hi User, Thank You for visiting My Blog. If you wish, please share your genuine Feedback or comments only related to this Blog Posts. It is my humble request that, please do not post any Spam comments or Advertising kind of comments, which will be Ignored.