Forum Discussion
Need to use If Condition In Power BI Desktop.
Send a onedrive, googledrive, dropbox, we transfer link in the post.
Regards,
MFelix
Hi MFelix,
Please find the sample file.
https://www.dropbox.com/s/liep5krpxcebyvh/Sample.xlsx?dl=0
Thanks,
Arvind
- MFelix7 years agoSuper User
Hi arvindyadav,
Create the following two measures:
Profict per employee = IF ( SUM ( Sheet1[Profit] ) > CALCULATE ( AVERAGE ( Sheet1[Profit] ); ALL ( Sheet1[AM] ) ); SUM ( Sheet1[Profit] ); CALCULATE ( AVERAGE ( Sheet1[Profit] ); ALL ( Sheet1[AM] ) ) ) Total Profit = IF ( HASONEFILTER ( Sheet1[AM] ); [Profict per employee]; SUMX ( SUMMARIZE ( ALL ( Sheet1 ); Sheet1[Date].[Month]; Sheet1[AM]; "ProfitTotal"; [Profict per employee] ); [ProfitTotal] ) )The use the second one to add to your visual should work, see attached PBIX file.
Regards,
MFelix
- arvindyadav7 years agoPost Partisan
Hi MFelix,
Now the total issue fixed but the average is not correct. There are 17 AM's and the total profit is 279384.88.
Then The average is 279384.88/17=16434.40. But in your case the average display as 173.85 which is not correct.
Please find the attached.
Thanks,
Arvind
- arvindyadav7 years agoPost Partisan
- MFelix7 years agoSuper User
Hi arvindyadav,
Replace the first measure by:
Profict per employee = IF ( SUM ( Sheet1[Profit] ) = BLANK (); BLANK (); IF ( SUM ( Sheet1[Profit] ) > AVERAGEX ( SUMMARIZE ( ALL ( Sheet1 ); Sheet1[Date].[Month]; Sheet1[AM]; "ProfitTotal"; SUM ( Sheet1[Profit] ) ); [ProfitTotal] ); SUM ( Sheet1[Profit] ); AVERAGEX ( SUMMARIZE ( ALL ( Sheet1 ); Sheet1[Date].[Month]; Sheet1[AM]; "ProfitTotal"; SUM ( Sheet1[Profit] ) ); [ProfitTotal] ) ) )See attach the correct PBIX file.
Regards,
MFelix
- arvindyadav7 years agoPost Partisan
Hi MFelix,
Not works. For every month and individual month, the total is the same.
Please find attached.
- MFelix7 years agoSuper User
- arvindyadav7 years agoPost Partisan
No
- MFelix7 years agoSuper User
Hi arvindyadav,
As I refer this calculation are based on context so if your model setup is different then the final result will not match what you need.
Can you share a mockup of your model so I can make the right adjustment to the formulas?
If you want you can share it trhough private message to avoid publishing sensitive data.
Regards,
MFelix