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
frostys
Helper I
Helper I

Time Slicer

Hi !

 

I put a time slicer in a report :

 

Capture.PNG

 

The data come directly from a "date" column. 

 

I try to make an automatic selection for the current year and current month selected. (Exemple: if I select june 2018, it auto select january-may. If I select january 2019 it auto select january-december 2018).

 

Thank a lot !

 

4 REPLIES 4
Anonymous
Not applicable

So the way I would do this is through changing the measure you are using for the visuals.

 

something like this should work, when a single month is selected it will calculate the specificd measure from the start of the calendar year to the previous month.

 

Measure =
IF (
    HASONEVALUE ( DateTable[Month] ),
    CALCULATE (
        [Measure],
        DATESBETWEEN (
            DateTable[Date],
            DATE ( YEAR ( MAX ( DateTable[Date] ) ), 1, 1 ),
            EOMONTH ( MAX ( DateTable[Date] ), -1 )
        )
    )
)

 

I change some syntax who were not working, so this is the syntax who work

 

date2 = 

IF (
    HASONEVALUE ( 'Data input'[Date].[Month] );
    CALCULATE (
        
        DATESBETWEEN (
            'Data input'[Date].[Date];
            DATE ( YEAR ( MAX ( 'Data input'[Date].[Date] ) ); 1; 1 );
            EOMONTH ( MAX ( 'Data input'[Date].[Date] ); -1 )
        )
    )
)
        

Otherwise, is is not accept this measure as slicer

HI @frostys,

 

Current power bi not support to create dynamic calculated column/table based on slicer/filter.

In addition, measure is possible to dynamic change based on slicer/filter, but power bi not support to use as source of slicer or axis of visual.

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
Anonymous
Not applicable

So does the measure work for your needs?

 

The reason you had to make the changes are two fold

1. You are in a different region hence the , vs ;

2. You do not have a datetable linked to your data table hence having to use the inbuilt datetable.

 

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.