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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
johnwrite
Frequent Visitor

Filter Datetime Column based on another Column

Hi Guys ,

 

I am new to power BI .I want the visuals to interact in such a way that only some of the filters in the selected visual apply to the other visual, while other filters do not. Below is the data table i have 

 

 

cws.JPG

 

 

 Now what I need is the rows of 'day' and 'count' present in between 'cws' and 'cwe' . Null values will be there for first two columns , so i am unable to filter it by comparing day with cws and cwe columns.  By having a visual filter for cws and cwe , it should be able to show me the day and counts between september 3rd and september 11th i.e., September 6th and september 7th from day column along with their counts . 

 

cwe.jpg

I am also fine if I can have another line that starts from september 6th and end with september 7th .  Any inputs/solution on this would be really helpful to me .

 

 Thanks

 

 

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

Hi @johnwrite,

 

According to your description, you want to use the column “cws” and “cwe” to filter the records, right?

 

If as I said, you can refer to below steps:

Source table:

Capture.PNG
 

Open the Advanced Editor to add two variables to get the values from “cws“ and “cwe”.


Formulas:


Cws = List.First(Table.SelectRows(Table.SelectColumns(#"Changed Type","Cws"), each [Cws] <> null)[Cws]),
Cwe =List.First(Table.SelectRows(Table.SelectColumns(#"Changed Type","Cwe"), each [Cwe] <> null)[Cwe]),

 

Add a filter rows function and use above variables to filter records.


Formula:
#"Filtered Rows" = Table.SelectRows(#"Changed Type", each [Day] >= Cws and [Day] <= Cwe )

 

Result:

Capture2.PNG
 

Full query:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WUtIBIQt9YwN9IwNDMyDbzFIpVgdJwhAugSRuqQ8XNjZGETeCiRsZooibwcWNUMTN0cyx1DeGiQAtgdsCQrGxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Cws = _t, Cwe = _t, Day = _t, Count = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Cws", type date}, {"Cwe", type date}, {"Day", type date}, {"Count", Int64.Type}}),
    Cws = List.First(Table.SelectRows(Table.SelectColumns(#"Changed Type","Cws"), each [Cws] <> null)[Cws]),
    Cwe =List.First(Table.SelectRows(Table.SelectColumns(#"Changed Type","Cwe"), each [Cwe] <> null)[Cwe]),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each [Day] >= Cws and [Day] <= Cwe )
in
#"Filtered Rows"

 

 

Reference:


List.First
Table.SelecRows

Table.SelectColumns

 

Regards,
Xiaoxin Sheng

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

View solution in original post

1 REPLY 1
v-shex-msft
Community Support
Community Support

Hi @johnwrite,

 

According to your description, you want to use the column “cws” and “cwe” to filter the records, right?

 

If as I said, you can refer to below steps:

Source table:

Capture.PNG
 

Open the Advanced Editor to add two variables to get the values from “cws“ and “cwe”.


Formulas:


Cws = List.First(Table.SelectRows(Table.SelectColumns(#"Changed Type","Cws"), each [Cws] <> null)[Cws]),
Cwe =List.First(Table.SelectRows(Table.SelectColumns(#"Changed Type","Cwe"), each [Cwe] <> null)[Cwe]),

 

Add a filter rows function and use above variables to filter records.


Formula:
#"Filtered Rows" = Table.SelectRows(#"Changed Type", each [Day] >= Cws and [Day] <= Cwe )

 

Result:

Capture2.PNG
 

Full query:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WUtIBIQt9YwN9IwNDMyDbzFIpVgdJwhAugSRuqQ8XNjZGETeCiRsZooibwcWNUMTN0cyx1DeGiQAtgdsCQrGxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Cws = _t, Cwe = _t, Day = _t, Count = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Cws", type date}, {"Cwe", type date}, {"Day", type date}, {"Count", Int64.Type}}),
    Cws = List.First(Table.SelectRows(Table.SelectColumns(#"Changed Type","Cws"), each [Cws] <> null)[Cws]),
    Cwe =List.First(Table.SelectRows(Table.SelectColumns(#"Changed Type","Cwe"), each [Cwe] <> null)[Cwe]),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each [Day] >= Cws and [Day] <= Cwe )
in
#"Filtered Rows"

 

 

Reference:


List.First
Table.SelecRows

Table.SelectColumns

 

Regards,
Xiaoxin Sheng

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

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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