Forum Discussion
Need help with DAX Formula
- 9 months ago
Hi ahmer_malick ,
Thanks for the update and additional details.
Please try the below updated measure, which evaluates the last available Promise Date per Branch Plant and SKU within each month and returns the corresponding Quantity Available value:
Qty Available Last Actual Day In Month = VAR _SelEOM = MAX ( 'Calendar'[EOM] ) VAR _LastDateInMonth = CALCULATE ( MAX ( 'Sheet1'[Promise Date] ), ALLEXCEPT ( 'Sheet1', 'Sheet1'[Branch/ Plant], 'Sheet1'[Parent 2nd Item Number] ), 'Sheet1'[Promise Date] <= _SelEOM, 'Sheet1'[Promise Date] > EOMONTH ( _SelEOM, -1 ) ) RETURN CALCULATE ( SUM ( 'Sheet1'[Quantity Available] ), FILTER ( ALLEXCEPT ( 'Sheet1', 'Sheet1'[Branch/ Plant], 'Sheet1'[Parent 2nd Item Number] ), 'Sheet1'[Promise Date] = _LastDateInMonth ) )Please let us know if it gives the expected output for all SKUs across branches.
Thank you.
Hi ahmer_malick ,
Thanks for posting your question in the Fabric Community.
As MasonMA mentioned, the issue comes from not having a proper Date table in your model. Creating a dedicated Date table and relating it to 'DEMAND & SUPPLY (3)'[Sched Pick] will allow MAX(Date) to behave as expected and ensure the measure returns results for each month-end, not just the current one.
This change will make your calculation dynamic across all months.
In addition, to help test and suggest working solutions, and as suggested by tayloramy , could you please provide sample data or sample pbix file, and ensure that it is shared with the appropriate permissions?
You can find guidance here: How to provide sample data in the Power BI Forum - Microsoft Fabric Community
This will make it easier to reproduce your scenario and provide more targeted help.
Please reach out for further assistance.
Thank you.
I tried that but its only giving me 1 month in next 3 years and not MOM basis