Forum Discussion
Facing issue with DATEADD function
Hi all, I am a beginnering and try to flow previous year cost using DATEADD function. But, I am not getting the desired results.
I am sharing the screenshot of the result that I am getting. Please have a look and help me.
Thanks
Please let me know if you need more information.
Hi,
Try this approach
- Create a Calendar table with calculated column formulas for Year, Month name and month number
- Create a relationship (Many to One and Single) from the Date column of the Fact table to the Date column of the Calendar table
- To your visual/filter/slicer, dray Year/Month name from the Calendar table
- Write this measure
Measure = calculate([Cost of logistics],previousmonth(calendar[date]))
6 Replies
- DekuSuper User
Can you share a picture of the data model please
- Ashish_MathurSuper User
Hi,
Try this approach
- Create a Calendar table with calculated column formulas for Year, Month name and month number
- Create a relationship (Many to One and Single) from the Date column of the Fact table to the Date column of the Calendar table
- To your visual/filter/slicer, dray Year/Month name from the Calendar table
- Write this measure
Measure = calculate([Cost of logistics],previousmonth(calendar[date]))
- v-karpurapudCommunity Support
Hi devaverma
Thank you for reaching out to the Microsoft Fabric Community Forum.
The issue you're encountering with the DATEADD function is most likely related to the absence of a proper date table. For DATEADD to work correctly, it requires a continuous date table with no missing dates. Additionally, the order_date field you are using 'data dimensions'[order_date] must come from a marked date table within your data model.
If your date table is not properly linked to the fact table or if there are any gaps in the order_date values, the DATEADD function may return blank or unexpected results.
As suggested by Ashish_Mathur , try creating a calendar table and marked it as the official date table. Make sure this calendar is related to fact table through the order_date field.
If the issue still persists after implementing the calendar table, kindly share the PBIX file so we can investigate further and assist you more effectively.
If my response has resolved your query, please mark it as the Accepted Solution to assist others. Additionally, a 'Kudos' would be appreciated if you found my response helpful.
Thank You
- v-karpurapudCommunity Support
Hi devaverma
May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.
Thank you.
- v-karpurapudCommunity Support
Hi devaverma
I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank you. - v-karpurapudCommunity Support
Hi devaverma
I hope this information is helpful. Please let me know if you have any further questions or if you'd like to discuss this further. If this answers your question, please Accept it as a solution and give it a 'Kudos' so others can find it easily.
Thank you.