Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowThe Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.
Hi Experts,
I have Week data and i have period slicer like 1Month , 3Month and 6Month . so when the user clicks on 1Month then line chart X-axis should display as Daywise like 1st picture (Note : I don't have Month column here it should display according to week number). when the user clicks on 3month and 6month then Line chart should display as Week wise 2nd picture. Any help appriciated please.
Solved! Go to Solution.
Hi bhanu_gautam ,thanks for the quick reply, I'll add more.
Hi @Bajigntrr ,
Regarding your question, the "Format" function requires at least two parameters, and the image you provided is incomplete, as it only has one parameter. Also, I believe what you might need is a field parameter, not a measure.
Use report readers to change visuals (preview) - Power BI | Microsoft Learn
The Table data is shown below:
Use the following DAX expression to create a datetable
Calendar =
ADDCOLUMNS (
CALENDAR ( DATE ( 2025, 1, 1 ), DATE ( 2025, 12, 31 ) ),
"WeekNumber", WEEKNUM ( [Date] ),
"YearMonth", FORMAT ( [Date], "YYYYMM" )
)
Create field parameters whose Dax expressions you can modify to suit your needs
Parameter = {
("1Month", NAMEOF('Calendar'[WeekNumber]), 0),
("3Month", NAMEOF('Calendar'[YearMonth]), 1),
("6Month", NAMEOF('Calendar'[YearMonth]), 2)
}
Final output
Best Regards
Hi bhanu_gautam ,thanks for the quick reply, I'll add more.
Hi @Bajigntrr ,
Regarding your question, the "Format" function requires at least two parameters, and the image you provided is incomplete, as it only has one parameter. Also, I believe what you might need is a field parameter, not a measure.
Use report readers to change visuals (preview) - Power BI | Microsoft Learn
The Table data is shown below:
Use the following DAX expression to create a datetable
Calendar =
ADDCOLUMNS (
CALENDAR ( DATE ( 2025, 1, 1 ), DATE ( 2025, 12, 31 ) ),
"WeekNumber", WEEKNUM ( [Date] ),
"YearMonth", FORMAT ( [Date], "YYYYMM" )
)
Create field parameters whose Dax expressions you can modify to suit your needs
Parameter = {
("1Month", NAMEOF('Calendar'[WeekNumber]), 0),
("3Month", NAMEOF('Calendar'[YearMonth]), 1),
("6Month", NAMEOF('Calendar'[YearMonth]), 2)
}
Final output
Best Regards
Hi @bhanu_gautam , I have dedicated t_calender table whihc has Day and Week ..
so from that table, when i write the switch condition , giving an error like this ..could you help
Create a Date Table: Ensure you have a date table in your model. If not, create one using DAX.
DateTable =
ADDCOLUMNS (
CALENDAR (MIN(YourData[Date]), MAX(YourData[Date])),
"Year", YEAR([Date]),
"MonthNumber", MONTH([Date]),
"MonthName", FORMAT([Date], "MMMM"),
"WeekNumber", WEEKNUM([Date]),
"Day", DAY([Date])
)
Create a Slicer Table: Create a table for the period slicer.
PeriodSlicer =
DATATABLE (
"Period", STRING,
{
{"1Month"},
{"3Month"},
{"6Month"}
}
)
Create a measure that will determine the axis based on the slicer selection.
SelectedPeriod = SELECTEDVALUE(PeriodSlicer[Period])
DynamicAxis =
SWITCH (
TRUE(),
[SelectedPeriod] = "1Month", FORMAT(YourData[Date], "dd MMM"),
[SelectedPeriod] = "3Month", "Week " & WEEKNUM(YourData[Date]),
[SelectedPeriod] = "6Month", "Week " & WEEKNUM(YourData[Date]),
FORMAT(YourData[Date], "dd MMM")
Add the Slicer to Your Report: Add the PeriodSlicer table to your report and create a slicer visual from it.
Use the Dynamic Axis in Your Line Chart: In your line chart, use the DynamicAxis measure for the X-axis.
Adjust the Line Chart: Ensure your line chart is set to display data points based on the DynamicAxis measure.
Proud to be a Super User! |
|
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the February 2025 Power BI update to learn about new features.
User | Count |
---|---|
86 | |
81 | |
53 | |
37 | |
35 |