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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Auto select previous months

Hi guys,

 

I want to know if it is possible select one month, and the others selected automatically, like a MTD (I suppose). I have an alternative, using quarters checkbox, but, what i really want is select one month from the list.

 

Example: I choose the August month, and automatically select all previous months (Jan, fev, mar, apr, mai, jun, jul from 2015 and 2016).

 

What happens when i choose August:

 

What happens.

 

 

What i want:

 

what i want

 

I know the time slicer app, but i really don't like this app.

1 ACCEPTED SOLUTION
Vvelarde
Community Champion
Community Champion

@Anonymous

 

Try this:

 

Create a table with Months (1....12) Use this as Slicer. Don't related with your data table.

 

Create a Measure: 

 

ValuesChart =
VAR MAXMONTH =
    VALUES ( Months[Month] )
RETURN
    IF (
        VALUES ( Table1[Month] ) <= MAXMONTH,
        CALCULATE ( SUM ( Table1[Values] ) ),
        BLANK ()
    )

Use this measure in your chart.

 




Lima - Peru

View solution in original post

12 REPLIES 12
Vvelarde
Community Champion
Community Champion

@Anonymous

 

Try this:

 

Create a table with Months (1....12) Use this as Slicer. Don't related with your data table.

 

Create a Measure: 

 

ValuesChart =
VAR MAXMONTH =
    VALUES ( Months[Month] )
RETURN
    IF (
        VALUES ( Table1[Month] ) <= MAXMONTH,
        CALCULATE ( SUM ( Table1[Values] ) ),
        BLANK ()
    )

Use this measure in your chart.

 




Lima - Peru
Anonymous
Not applicable

Hi @Vvelarde,

 

I tried your solution but I'm with some doubts.

 

I created a table with a Month column (1,2,3,4...,12)

 

1.JPG

 

Then I create a measure, but I've doubts what is the table/column that I need to put in "CALCULATE ( SUM...)"

 

ValuesChart =
VAR MAXMONTH =
    VALUES ( Dimensão Data[Month] )
RETURN
    IF (
        VALUES ( Tabela1[Month] ) <= MAXMONTH,
        CALCULATE ( SUM ( Tabela1[Month] ) ),
        BLANK ()
    )

I've already a Table with a date, year, month.. but I didn't related them.

 

2.JPG

 

I have my Month slicer from my Tabela1 data

 

3.JPG

What is the chart configuration?

 

4.JPG

 

Thanks in advance,

Flávio.

@Anonymous

 

hi, you have 

 

ValuesChart =
VAR MAXMONTH =
    VALUES ( Tabela1[Month] )
RETURN
    IF (
        VALUES ( DimensaoData[Month] ) <= MAXMONTH,
        ***YOUR COLUMN TO SHOW AS VALUE IN THE CHART***),
        BLANK ()
    )

 

In the chart Use DimensaoData for Axis and Legend.

 

Note: In you your DimensaoData the months are numeric. (1...12). If you don't have please add this column

 




Lima - Peru
Anonymous
Not applicable

@Vvelarde

 

I can't get the chart. What is wrong?

 

5.jpg

what is the message in ver Detalhes




Lima - Peru
Anonymous
Not applicable

MdxScript(Model) (6, 46) miscalculation as 'OINV AND ORION' [Values Chart] was provided a table of various values where it was expected one value

@Anonymous

 

I made a sample of this.

 

Sample




Lima - Peru
Anonymous
Not applicable

@Vvelarde thank you,

 

It is possible replicate your code in a card label, to show me a % ?

 

I'm using your code unsuccessful in my card label:

 

 

Var = 
VAR MAXMONTH =
    VALUES ( 'Calendar'[MonthNumber] )
RETURN
    IF (
        VALUES ( 'Calendar'[MonthNumber]) <= MAXMONTH;
        CALCULATE ( DIVIDE('OINV E ORIN'[Variação Current vs Previous Year tons Activos];'OINV E ORIN'[Consumo de clientes Tons Previous Year];0) );
        BLANK ()
    )

 

1.JPG

 

@Anonymous

 

The measure fail becasuse There is not a unique Calendar's Month selected, in the chart this work because your Axis is the each month so Values is a unique row.

 

What is the %  that you want to show




Lima - Peru
Anonymous
Not applicable

my goal is to show in my card label the previous year variance in %. You're right, with this calendar I'm unable to show any result. There is other way using your code or the same logic?

 

my main code that I want the % is:

 

 

Variação Current vs Previous Year em % perda de Volume = DIVIDE('OINV E ORIN'[Variação Current vs Previous Year tons Activos];'OINV E ORIN'[Consumo de clientes Tons Previous Year])

 

 

 

"subcodes"...:

 

Variação Current vs Previous Year tons Activos:

 

 

Variação Current vs Previous Year tons Activos = 'OINV E ORIN'[Consumo de clientes Activos Current Year em Tons]-'OINV E ORIN'[Consumo de clientes Activos Previous Year em Tons]

 

Consumo de clientes Tons Previous Year:

 

Consumo de clientes Tons Previous Year = CALCULATE(SUM('OINV E ORIN'[Quantidade Tons]);FILTER('OINV E ORIN';'OINV E ORIN'[Estado Ano]="Previous"))

Consumo de clientes Activos Previous Year em Tons:

 

Consumo de clientes Activos Previous Year em Tons = CALCULATE(SUM('OINV E ORIN'[Quantidade Tons]);FILTER('OINV E ORIN';'OINV E ORIN'[Inactivo]<>"Y");FILTER('OINV E ORIN';'OINV E ORIN'[Estado Ano]="Previous"))

 

Anonymous
Not applicable

anyone?!

I dont know of a way to dynamically default slicers. I am sure this is a feature that is coming. You can statically default slicers by selecting the months you want then saving. When you or someone else views the report, then those months that were highlighted when you saved will be the default selection on the filters. 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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