Forum Discussion
DAX Formula
- 3 years ago
Hi , AxelKAp
Thanks for your quick response and sorry for the delay response due to the different work time zone.
For this issue , i ignore one judgement in dax , you can try to use this dax then we can get the right result:
Fees in = VAR _amount_month = [Month Total] VAR _PO = [PO Number] VAR _date = [Invoice AL Date] VAR _AL = [Invoice Number AL] VAR _amount = [PO Amount Total] VAR _t = FILTER ( 'Table', 'Table'[PO Number] = _PO && YEAR ( 'Table'[Invoice AL Date] ) = YEAR ( _date ) && MONTH ( 'Table'[Invoice AL Date] ) = MONTH ( _date ) ) VAR _show_AL = MINX ( _t, [Invoice Number AL] ) RETURN IF ( _amount_month < 800 && _AL = _show_AL, 20, IF ( _amount_month < 800 && _AL <> _show_AL, 0, _amount * 0.025 ) )We just need to add the "YEAR('Table'[Invoice AL Date]) = YEAR( date) && MONTH('Table'[Invoice AL Date]) = MONTH( date)" logic judgement in the "_t" parameter , the result is as follows:
Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!
Best Regards,
Aniya Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hello v-yueyunzh-msft,
First of all thank you for your help !
So I tested your solution but I have changed something in your solution, because here I don't need the calculated column Month Total because the rule to calculate the fees is only made with the PO Amount Total. I have this now:
It's working for the most of the fees but sometimes I have it's not working. I 'm sharing with example when it's not working.
You can see for the PO 5110622278 I have 1 line with 0€ (OK) but i have 2 lines with 20€ of fees but I need 1 line with 20€.
Thanks again for your support 😉
Hi , AxelKAp
Thanks for your quick response and sorry for the delay response due to the different work time zone.
For this issue , i ignore one judgement in dax , you can try to use this dax then we can get the right result:
Fees in =
VAR _amount_month = [Month Total]
VAR _PO = [PO Number]
VAR _date = [Invoice AL Date]
VAR _AL = [Invoice Number AL]
VAR _amount = [PO Amount Total]
VAR _t =
FILTER (
'Table',
'Table'[PO Number] = _PO
&& YEAR ( 'Table'[Invoice AL Date] ) = YEAR ( _date )
&& MONTH ( 'Table'[Invoice AL Date] ) = MONTH ( _date )
)
VAR _show_AL =
MINX ( _t, [Invoice Number AL] )
RETURN
IF (
_amount_month < 800
&& _AL = _show_AL,
20,
IF ( _amount_month < 800 && _AL <> _show_AL, 0, _amount * 0.025 )
)
We just need to add the "YEAR('Table'[Invoice AL Date]) = YEAR( date) && MONTH('Table'[Invoice AL Date]) = MONTH( date)" logic judgement in the "_t" parameter , the result is as follows:
Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!
Best Regards,
Aniya Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly