Forum Discussion
Need to use If Condition In Power BI Desktop.
Hi arvindyadav,
Again is a question of context, since the measure is based on the total profit value compared with the average you are getting the total profit and not the sum of the above values you need to do a SUMX statment something like this should work:
IF (
HASONEVALUE ( Table[Employee] );
IF (
SUM ( Table[Profit] )
> CALCULATE ( [Average Profit/Employee]; ALL ( Table[Employee] ) );
SUM ( Table[Profit] );
CALCULATE ( [Average Profit/Employee]; ALL ( Table[Employee] ) )
);
SUMX (
Table;
IF (
SUM ( Table[Profit] )
> CALCULATE ( [Average Profit/Employee]; ALL ( Table[Employee] ) );
SUM ( Table[Profit] );
CALCULATE ( [Average Profit/Employee]; ALL ( Table[Employee] ) )
)
)
)
Regards,
MFelix
Hi MFelix,
Have got any solution regarding my questions?
Everything is fine but the issue is in total profit.
Thanks,
Arvind.
- MFelix7 years agoSuper User
HI arvindyadav,
Although you have an image is not clear on the way the tables and the fields in you matrix relate to each other try to do the following.
Split the measure in two:
Profit/Average = IF ( SUM ( Table[Profit] ) > CALCULATE ( [Average Profit/Employee]; ALL ( Table[Employee] ) ); SUM ( Table[Profit] ); CALCULATE ( [Average Profit/Employee]; ALL ( Table[Employee] ) ) ) Total Profit = IF ( HASONEVALUE ( Table[Employee] ); [Profit/Average]; SUMX ( Table; [Profit/Average] ) )Then use the last measure on your table.
If you cannot do it can you share a sample of you data maybe through private message so I can check the calculations and setup of the model?
Regards,
MFelix
- arvindyadav7 years agoPost Partisan
The above procedure is the same as the previous one so I am still getting the same value as previous.
How to insert an attachment in the thread. I don't see any option to attach the file. Can you explain to me how I can upload the file?
- MFelix7 years agoSuper User
Send a onedrive, googledrive, dropbox, we transfer link in the post.
Regards,
MFelix