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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Umair_Aslam
Helper I
Helper I

Get January to current moth names of current year.

I want to get names of January to current month in a column like Jan, Feb, mar etc 

can anyone know about it how to get it from calendar. 

1 ACCEPTED SOLUTION

Hi @Umair_Aslam ,

 

In your calendar table, add a new custom column like this:

// Will show all of current month
Current YTD =
if Date.IsInCurrentYear([Date]) and [Date] <= Date.EndOfMonth(Date.From(DateTime.LocalNow()))
then "Current YTD"
else null

 

Or like this:

 

// Will show only up to today
Current YTD =
if Date.IsInCurrentYear([Date]) and [Date] <= Date.From(DateTime.LocalNow())
then "Current YTD"
else null

 

Use your new column in your slicer, in the Slicer Selection option uncheck 'Use Ctrl to multi-select', and in the visual-level filter set 'Current YTD' to 'Is not blank'.

This will give you a single check box that you can toggle on/off.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

4 REPLIES 4
Umair_Aslam
Helper I
Helper I

It isn't working like what I want. I want a single check box when select it then it will show visual from Jan to current month data of current year when I uncheck it it will show whole data can anybody help for this filter

Hi @Umair_Aslam ,

 

In your calendar table, add a new custom column like this:

// Will show all of current month
Current YTD =
if Date.IsInCurrentYear([Date]) and [Date] <= Date.EndOfMonth(Date.From(DateTime.LocalNow()))
then "Current YTD"
else null

 

Or like this:

 

// Will show only up to today
Current YTD =
if Date.IsInCurrentYear([Date]) and [Date] <= Date.From(DateTime.LocalNow())
then "Current YTD"
else null

 

Use your new column in your slicer, in the Slicer Selection option uncheck 'Use Ctrl to multi-select', and in the visual-level filter set 'Current YTD' to 'Is not blank'.

This will give you a single check box that you can toggle on/off.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




I have Solved my problem by using two visuals selecting bookmark 

BA_Pete
Super User
Super User

Hi @Umair_Aslam ,

 

Try this in a new blank query:

let
    Source =
    List.Transform(
        {
            Number.From( #date( Date.Year(DateTime.LocalNow()), 01, 01))
            ..
            Number.From( Date.EndOfMonth( Date.From( DateTime.LocalNow())))
        },
        each Date.From(_)
    ),
    convToTable = Table.FromList(Source, Splitter.SplitByNothing(), {"Date"}, null, ExtraValues.Error),
    addShortMonthName = Table.AddColumn(convToTable, "ShortMonthName", each Text.Start(Date.MonthName([Date]), 3))
in
    addShortMonthName

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors