Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
I have a dim Calendar and dim CalendarVisual
i have dimCalendar Year in slicer and dimCalendar MonthName in second slicer.
I have a column chart where I will put a parameter in X axis. User can choose to see dates in x or month name in x axis.
I have created two measures, and both work, but only if I either use dates or use Year and Month, not with month name.
If I use month name, it shows no data.
my measures:
Sales Calendar Date =
VAR MaxDate = MAX('dim Calendar'[Calendar Date])
VAR MinDate = DATE(YEAR(MaxDate), 1, 1)
VAR Result =
IF(
HASONEVALUE('dim Calendar'[Year and month]) &&
MAX( 'dim VisualCalendar'[Calendar Date] ) <= maxDate &&
MIN( 'dim VisualCalendar'[Calendar Date] ) > MinDate,
CALCULATE(
[Net Amount],
FILTER(ALL('dim Calendar'),
'dim Calendar'[Calendar Date]= VALUES('dim VisualCalendar'[Calendar Date])
)
),
BLANK()
)
RETURN
Result
Sale Year and Month=
VAR MaxDate = MAX('dim Calendar'[Calendar Date])
VAR MinDate = DATE(YEAR(MaxDate), 1, 1)
VAR Result =
IF(
HASONEVALUE('dim Calendar'[Year and month]) &&
MAX( 'dim VisualCalendar'[Calendar Date] ) <= maxDate &&
MIN( 'dim VisualCalendar'[Calendar Date] ) > MinDate,
CALCULATE(
[Net Amount],
FILTER(ALL('dim Calendar'),
'dim Calendar'[Year and Month]= VALUES('dim VisualCalendar'[Year and Month])
)
),
BLANK()
)
RETURN
Result
Solved! Go to Solution.
Hi @MegaOctane1,
Thank you for reaching out to the Microsoft fabric community forum.
Thank you @Jai-Rathinavel, for your response regarding the issue.
Year and Month are not unique by themselves since they repeat for each date in that month. That’s why we usually pair them with date-based filters like MAX/MIN to get accurate results.
You can combine both your measures into one using a SWITCH statement based on the user's selection (such as Date, Month Name, or YearMonth). However, the easiest and cleanest way to handle this is by using Field Parameters. This allows you to switch the X-axis dynamically in the visual without writing complex DAX.
Please find attached Pbix File and screenshot for your reference
If I misunderstand your needs or you still have problems on it, please feel free to let us know.
If the response has addressed your query, please Accept it as a solution and give a 'Kudos' so other members can easily find it
Best Regards,
Harshitha.
Community Support Team
@MegaOctane1 The problem occurs because "Month Name" by itself isn't unique—it repeats every year. To avoid confusion and ensure accurate filtering, you should include the Year along with the Month Name when applying filters. Please try out the below dax and see if it help.
Sale New =
VAR MaxDate = MAX('dim Calendar'[Calendar Date])
VAR MinDate = DATE(YEAR(MaxDate), 1, 1)
VAR Result =
IF(
(HASONEVALUE('dim Calendar'[Year and Month]) || HASONEVALUE('dim Calendar'[Month Name])) &&
MAX('dim VisualCalendar'[Calendar Date]) <= MaxDate &&
MIN('dim VisualCalendar'[Calendar Date]) > MinDate,
CALCULATE(
[Net Amount],
FILTER(ALL('dim Calendar'),
('dim Calendar'[Year and Month] = VALUES('dim VisualCalendar'[Year and Month]) ||
('dim Calendar'[Month Name] = VALUES('dim VisualCalendar'[Month Name]) &&
'dim Calendar'[Year] = VALUES('dim VisualCalendar'[Year])))
)
),
BLANK()
)
RETURN
Result
Proud to be a Super User! | |
Oh.. I will try. But Year and month is not unique either. This repeats as many times as there are dates?
can I combine both measures into one somehow?
Hi @MegaOctane1,
Thank you for reaching out to the Microsoft fabric community forum.
Thank you @Jai-Rathinavel, for your response regarding the issue.
Year and Month are not unique by themselves since they repeat for each date in that month. That’s why we usually pair them with date-based filters like MAX/MIN to get accurate results.
You can combine both your measures into one using a SWITCH statement based on the user's selection (such as Date, Month Name, or YearMonth). However, the easiest and cleanest way to handle this is by using Field Parameters. This allows you to switch the X-axis dynamically in the visual without writing complex DAX.
Please find attached Pbix File and screenshot for your reference
If I misunderstand your needs or you still have problems on it, please feel free to let us know.
If the response has addressed your query, please Accept it as a solution and give a 'Kudos' so other members can easily find it
Best Regards,
Harshitha.
Community Support Team
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
76 | |
76 | |
55 | |
37 | |
34 |
User | Count |
---|---|
99 | |
56 | |
53 | |
44 | |
40 |