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
hollowyourdream
New Member

Daterange on multiple columns

Hi there! I have a lot of columns with datetime that i want to see every count. I getting them from sql query to postgres and now i want to filter my summs with one filter on daterange. How can I do it? 
I've tried to do that with 2 datetime params but it doesnt work

 

 

let
    Start=DateTime.ToText(StartDate),
    End=DateTime.ToText(VEndDate),
    Source = PostgreSQL.Database("host", "dbName",
    [Query="select count(cv.""Date1"") as Date1Cnt
        , count(cv.""Date2"") as Date2Cnt
        , count(cv.""Date3"") as Date3Cnt
        from schemeName.""TableName"" as cv
        where (cv.""Date1"" >= TO_TIMESTAMP('" &Start& "', 'dd.mm.yyyy hh24:mi') and cv.""Date1"" < TO_TIMESTAMP('" &End& "', 'dd.mm.yyyy hh24:mi') or cv.""Date1"" is null)
        and (cv.""Date2"" >= TO_TIMESTAMP('" &Start& "', 'dd.mm.yyyy hh24:mi') and cv.""Date2"" < TO_TIMESTAMP('" &End& "', 'dd.mm.yyyy hh24:mi') or cv.""Date2"" is null)
        and (cv.""Date3"" >= TO_TIMESTAMP('" &Start& "', 'dd.mm.yyyy hh24:mi') and cv.""Date3"" < TO_TIMESTAMP('" &End& "', 'dd.mm.yyyy hh24:mi') or cv.""Date3"" is null)
"])
in
    Source

 

 

 And there is sample of filtering in sql 😃 

 

9 REPLIES 9
CNENFRNL
Community Champion
Community Champion

After you verify your sql works well in Postgres, you may want to try Value.NativeQuery() function; the advantage is straightforward, you can 100% copy the sql from Postgres. For your reference, here's an article on passing parameters to sql in Value.NativeQuery.


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

also i've tred to do from that example , but i have an error: Query (2,14) Parametr M "EndDate" undefined in model type or parametr M cannot be used (sry for translation, my English is bad) 

Hi @hollowyourdream ,

 

Have you defined and referenced the ‘StartDate’ and'EndDate’ parameters correctly?

For example, the data type of the parameters?

v-lionel-msft_0-1619770298293.pngv-lionel-msft_1-1619770316122.png

 

Best regards,
Lionel Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

Yeah, i've seen this manual, but it is not work(

Hi @hollowyourdream ,

 

Considerations and limitations 

v-lionel-msft_0-1620292799217.png

It may be caused by this limitations.

 

Best regards,
Lionel Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

So, i've tried that with manual and it is not filtering(but i have bo error) 


let
Источник = PostgreSQL.Database("localhost:5432", "HrMetrics"),
hr_metrics_CvInfo = Источник{[Schema="hr_metrics",Item="CvInfo"]}[Data],
#"FilteredRows" = Table.SelectRows(hr_metrics_CvInfo, each [ApprovedCvDate] >= VoronkaStartDate and [ApprovedCvDate] <= VoronkaEndDate)
in
#"FilteredRows"

And have i any variants to do filter on multiple columns in postgres?

Okay, i really using postgres, but i heard that i can fake it as possible source. Is it true? And if it is, how can i do that?

How can i pass it throw filter or slice? I need user to select daterange 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.