Forum Discussion
SUMIF/IF formulas
Hi, I am trying to write the following excel formulas in DAX:
=SUMIF(O:O;"<="&O2;H:H) ---> sum column H for all values where O is less than or equal to the current O cell.
and
=IF(P2<=SUM(H:H)/10;1;IF(P2<=2*SUM(H:H)/10;2);"") ---> return 1 if P2 is less than or equal to the sum of column H divided by 10, return 2 if P2 is less than or equal to 2 times the sum of column H divided by 10, otherwise leave it blank
Is this possible?
Thanks
- Anonymous5 years ago
Hi Anonymous ,
According to your description, I created some data to show:
Here are the steps you can follow:
1. Create calculated table.
H = CALCULATE(SUM('Table'[O]),FILTER('Table','Table'[O]<=EARLIER('Table'[O])))P1 = SWITCH( TRUE(), 'Table'[P2]<=DIVIDE(SUM('Table'[H]),10),1, 'Table'[P2]<=DIVIDE(SUM('Table'[H]),10)*2, 2, BLANK())2. Result.
You can downloaded PBIX file from here.
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
2 Replies
- AnonymousNot applicable
Hi Anonymous ,
According to your description, I created some data to show:
Here are the steps you can follow:
1. Create calculated table.
H = CALCULATE(SUM('Table'[O]),FILTER('Table','Table'[O]<=EARLIER('Table'[O])))P1 = SWITCH( TRUE(), 'Table'[P2]<=DIVIDE(SUM('Table'[H]),10),1, 'Table'[P2]<=DIVIDE(SUM('Table'[H]),10)*2, 2, BLANK())2. Result.
You can downloaded PBIX file from here.
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- AnonymousNot applicable
thank you!