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
ageuffrard
Frequent Visitor

display months values until value selected in parameter

Hi everyone, 

 

I've got an Excel parameter : 

ageuffrard_0-1657613738279.png

 

I created a parameter in Power Query with the value selected.

 

I want to use this parameter as a filter in a table, but I want the table filtered to the month selected.

If I select 4 (for the month April), I want the table filtered with Jan, Feb, Mar, Apr.

 

How to do that please ?

Thanks for your help, have a good day.

Alexandre

 

1 ACCEPTED SOLUTION
Vijay_A_Verma
Super User
Super User

Insert below statement. Replace #"Changed Type" with your previous step and MonthParam with your Parameter name. 

= Table.SelectRows(#"Changed Type", each [Month] <= MonthParam)

Make sure MonthParam is created with Decimal number option. If not, you can use Number.From(MonthParam) in above expression.

See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Lc7BEQAhCAPAXnj7EI1ganHsv40DPH47YSDniEoTd6PcdmQk6FqYAShQQMCcL1m1hlWwwKZ7wTPZsMIOrJgC88C0l2gPEXhfNTtg9D/LEiSG3PsB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Month = _t, Sales = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Month", Int64.Type}, {"Sales", Int64.Type}}),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each [Month] <= MonthParam)
in
    #"Filtered Rows"

View solution in original post

4 REPLIES 4
Vijay_A_Verma
Super User
Super User

Insert below statement. Replace #"Changed Type" with your previous step and MonthParam with your Parameter name. 

= Table.SelectRows(#"Changed Type", each [Month] <= MonthParam)

Make sure MonthParam is created with Decimal number option. If not, you can use Number.From(MonthParam) in above expression.

See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Lc7BEQAhCAPAXnj7EI1ganHsv40DPH47YSDniEoTd6PcdmQk6FqYAShQQMCcL1m1hlWwwKZ7wTPZsMIOrJgC88C0l2gPEXhfNTtg9D/LEiSG3PsB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Month = _t, Sales = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Month", Int64.Type}, {"Sales", Int64.Type}}),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each [Month] <= MonthParam)
in
    #"Filtered Rows"

Thanks a lot, it works perfecly !

Vijay_A_Verma
Super User
Super User

I need to see your table. Whether month column has 1, 2....12 or Jan, Feb...Dec in text?

Hi Vijay,

It's "1, 2, ... 12" as number.

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