Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The 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.

Reply
Bajigntrr
Helper II
Helper II

1Month slicer to display day wise data

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.

Bajigntrr_0-1738910288131.png

Bajigntrr_1-1738910469710.png

 

 

1 ACCEPTED SOLUTION
v-zhouwen-msft
Community Support
Community Support

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:

vzhouwenmsft_0-1739154657363.png

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" )
)

vzhouwenmsft_1-1739154761425.png

Create field parameters whose Dax expressions you can modify to suit your needs

vzhouwenmsft_2-1739154851364.png

Parameter = {
    ("1Month", NAMEOF('Calendar'[WeekNumber]), 0),
    ("3Month", NAMEOF('Calendar'[YearMonth]), 1),
    ("6Month", NAMEOF('Calendar'[YearMonth]), 2)
}

Final output

vzhouwenmsft_3-1739155051784.png

 

vzhouwenmsft_4-1739155068153.png

 

Best Regards

View solution in original post

3 REPLIES 3
v-zhouwen-msft
Community Support
Community Support

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:

vzhouwenmsft_0-1739154657363.png

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" )
)

vzhouwenmsft_1-1739154761425.png

Create field parameters whose Dax expressions you can modify to suit your needs

vzhouwenmsft_2-1739154851364.png

Parameter = {
    ("1Month", NAMEOF('Calendar'[WeekNumber]), 0),
    ("3Month", NAMEOF('Calendar'[YearMonth]), 1),
    ("6Month", NAMEOF('Calendar'[YearMonth]), 2)
}

Final output

vzhouwenmsft_3-1739155051784.png

 

vzhouwenmsft_4-1739155068153.png

 

Best Regards

Bajigntrr
Helper II
Helper II

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

Bajigntrr_0-1738915520285.png

 

bhanu_gautam
Super User
Super User

@Bajigntrr 

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.




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Feb2025 NL Carousel

Fabric Community Update - February 2025

Find out what's new and trending in the Fabric community.

Top Kudoed Authors