Forum Discussion
Dynamic column header showing incorrect month and Year
- 1 year ago
Hi matmat ,
The issue arises because the CurrentMonthDate, PreviousMonthDate, and SameMonthLastYearDate measures are not properly retrieving the selected values from the slicer, leading to incorrect dates. To fix this, you need to ensure that the CurrentMonthDate measure accurately captures the slicer selection. Use the following DAX formula to calculate the CurrentMonthDate:
CurrentMonthDate = DATE( MAX('Calendar'[Year]), MAX('Calendar'[Month Num]), 1 )This ensures that the selected Year and Month Num from the slicer are properly reflected. For the PreviousMonthDate and SameMonthLastYearDate, you can use the corrected CurrentMonthDate as the basis for calculating the offsets:
PreviousMonthDate = EDATE([CurrentMonthDate], -1) SameMonthLastYearDate = EDATE([CurrentMonthDate], -12)In your field parameter, replace references to 'Calendar'[CurrentMonthDate] with the measure [CurrentMonthDate], ensuring that the field parameter reflects the updated logic. Here's the corrected Parameter 3:
Parameter 3 = { (FORMAT([CurrentMonthDate], "MMM YYYY"), NAMEOF('GA4_SitePages'[SelectedMonthVisits]), 2), (FORMAT([PreviousMonthDate], "MMM YYYY"), NAMEOF('GA4_SitePages'[PreviousMonthVisits]), 1), (FORMAT([SameMonthLastYearDate], "MMM YYYY"), NAMEOF('GA4_SitePages'[SamePeriodLastYearVisits]), 0) }With these changes, ensure that your slicer is connected to the Year and Month Num columns in the Calendar table. Verify that your Calendar table contains the correct range of dates and that the slicer selection is being passed correctly. This should resolve the issue and display the correct data for the current month, previous month, and the same period last year in the matrix visual.
Best regards,
- 1 year ago
Hi matmat
It seems like the issue might be related to how the dates are being calculated and formatted. Pls check the follwing steps.- Ensure that the CurrentMonthDate measure is correctly calculating the date based on the selected year and month
- The EDATE function should work correctly, but let's ensure the CurrentMonthDate is being passed correctly.
- Verify the Field Parameter Formatting - The FORMAT function should correctly format the dates, but let's ensure the dates are being calculated correctly before formatting.
Could you please provide sample data to fix your issue. Make sure that, when you are sharing the data don't include sensitive data. Thanks
Hi matmat ,
Thanks for reaching out.
Pls has your problem been solved? If so, accept the reply as a solution. This will make it easier for the future people to find the answer quickly.
If not, please provide a more detailed description, preferably some virtual sample data, and the expected results.
Best Regards,
Stephen Tao