The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
I have DAX syntax for -- >> if date = '2021' then use cost_amount_physical otherwise use Cost_amount_posted
Column = IF ( YEAR ( 'Table (2)'[Date] ) = 2021 && 'Table (2)'[cost_amount_physical] <> BLANK (), 'Table (2)'[cost_amount_physical], 'Table (2)'[Cost_amount_posted] )
need to add one more thing for the above query, "filter by Location which is on other sheet
if date = (Sheet 1)'2021' then use (Sheet1)cost_amount_physical otherwise use (Sheet1)Cost_amount_posted and filter by (Sheet2)location = "Acukland"
Desired Result | ||||||
Product | Date | cost_amount_physical | Cost_amount_posted | Store Cost | Location | |
Cycle | ######## | $10 | $10 | $0 | ||
Bike | ######## | $22 | $22 | Auckland | $22 |
Solved! Go to Solution.
@Reddyp Kindly update your code as below:-
column =
IF (
YEAR ( 'Inventory Invent_Trans_Fact'[Date_Financial] ) = 1990
&& 'Inventory Invent_Trans_Fact'[Cost_Amount_Physical] <> BLANK ()
&& RELATED ( 'Inventory Invent_Location_Dim'[Invent_Location_Id] ) = "W0400",
'Inventory Invent_Trans_Fact'[Cost_Amount_Physical],
'Inventory Invent_Trans_Fact'[Cost_Amount_Posted]
)
Best Regards,
Samarth
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin
HI @Reddyp ,
You could try below code:-
Column =
IF (
YEAR ( 'sheet (1)'[Date] ) = 2021
&& 'sheet (1)'[cost_amount_physical] <> BLANK ()
&& RELATED ( 'sheet(2)'[location] ) = "Auckland",
'sheet (1)'[cost_amount_physical],
'sheet (1)'[Cost_amount_posted]
)
Note:- I am considering you have relationship between both the sheets.
BR,
Samarth
Best Regards,
Samarth
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin
@Samarth_18 thank you, but this is not working
Error: The syntax for '&&' is incorrect. (DAX(IF( YEAR('Inventory Invent_Trans_Fact'[Date_Financial]) = 1990 && 'Inventory Invent_Trans_Fact'[Cost_Amount_Physical] <> BLANK(), && RELATED('Inventory Invent_Location_Dim'[Invent_Location_Id]) = 'W0400', 'Inventory Invent_Trans_Fact'[Cost_Amount_Physical], 'Inventory Invent_Trans_Fact'[Cost_Amount_Posted]))).
and relation is active
@Reddyp Kindly update your code as below:-
column =
IF (
YEAR ( 'Inventory Invent_Trans_Fact'[Date_Financial] ) = 1990
&& 'Inventory Invent_Trans_Fact'[Cost_Amount_Physical] <> BLANK ()
&& RELATED ( 'Inventory Invent_Location_Dim'[Invent_Location_Id] ) = "W0400",
'Inventory Invent_Trans_Fact'[Cost_Amount_Physical],
'Inventory Invent_Trans_Fact'[Cost_Amount_Posted]
)
Best Regards,
Samarth
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin
User | Count |
---|---|
59 | |
55 | |
53 | |
49 | |
30 |
User | Count |
---|---|
179 | |
87 | |
71 | |
48 | |
46 |