Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
Hi ,
I have following data model which has 2 fact tables 3 dimension tables and 1 bridge table to resolve many to many relationship.
I am trying to calculate Sales Volume since the contract Start Date for each "Product ID" in Contracts Table using following formula
Sales Volume Since Contract Start Date=
CALCULATE ([Total Volume],
FILTER (
SalesFact,
SalesFact[INVOICE_DATE]
>= MIN ( Contracts[Contract Start Date] )
),
SalesFact[PRODUCT_ID]
IN VALUES ( Contracts[Product ID] ),
SalesFact[BILL_TO_CUST_ID]
IN VALUES ( Contracts[Bill To ID] )
)
I get correct results when I throw this measure in a table which provides Context for MIN ( Contracts[Contract Start Date] ) . However, if I throw this measure in a card visual or in any other visual without a Contract Start date context I get incorrect results.
Can somone please tell me how can I resolve this? I think I need to use somekind of iterator function to get the result I need, but I can't seem to figure it out.
Thanks!
@BILearner , Try like. In case it joined with contract table and other tables, then what is need of in clause
sumx(summarize(Contracts, Contracts[Product ID] , "_1" ,CALCULATE ([Total Volume],
FILTER (
SalesFact,
SalesFact[INVOICE_DATE]
>= MIN ( Contracts[Contract Start Date] )
)
)) ,[_1])
Thank you for your advice @amitchandak I was able to build on your formula to come up with following forumla
@BILearner , Try with Values at Invoice Id or Date level
CALCULATE ([Total Volume],
FILTER (
SalesFact,
SalesFact[INVOICE_DATE]
>= MIN ( Contracts[Contract Start Date] )
),
SalesFact[PRODUCT_ID]
IN VALUES ( Contracts[Product ID] ),
SalesFact[BILL_TO_CUST_ID]
IN VALUES ( Contracts[Bill To ID] )
, values(SalesFact[INVOICE_ID]) //SalesFact[INVOICE_DATE]
)
@amitchandak Thank you for your response I tried both of your solution with Values(INVOICE_ID)// INVOICE_DATE.
It didn't work, it gave me the exact same result as my previous formula.
User | Count |
---|---|
41 | |
27 | |
23 | |
19 | |
16 |
User | Count |
---|---|
55 | |
35 | |
21 | |
18 | |
15 |