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
Anonymous
Not applicable

Please help to write dynamic query in Power BI

All rows where List_Date is before LAST DAY OF MONTH
AND
(Binding_Ag is between FIRST DAY OF MONTH and LAST DAY OF MONTH) OR (Expiration date is between FIRST DAY OF MONTH and LAST DAY OF MONTH) OR Binding_Ag is blank
 
List_Date Is a one column.
 
Binding_Ag is also one column.
 
Expiration date is a column
 
Please let me know can we add query for this.  Last Day of Month and First Day month is select by user and we need to show result. 

1 ACCEPTED SOLUTION
v-sihou-msft
Employee
Employee

@Anonymous

 

You just need to use FILTER() function to get the expected table context.

 

Create a calculated table like below:

 

Calculated Table =
VAR FirstDayOfMonth =
    DATE ( YEAR ( TODAY () ), MONTH ( TODAY () ), 1 )
VAR LastDayOfMonth =
    EOMONTH ( TODAY (), 0 )
RETURN
    FILTER (
        Table,
        Table[List_Date] < FirstDayOfMonth
            && ( Table[Binding_Ag] >= FirstDayOfMonth
            && Table[Binding_Ag] <= LastDayOfMonth )
            || ( Table[Expiration date] >= FirstDayOfMonth
            && Table[Expiration date] <= LastDayOfMonth )
            || Table[Expiration date] = BLANK ()
    )

Regards,

 

View solution in original post

1 REPLY 1
v-sihou-msft
Employee
Employee

@Anonymous

 

You just need to use FILTER() function to get the expected table context.

 

Create a calculated table like below:

 

Calculated Table =
VAR FirstDayOfMonth =
    DATE ( YEAR ( TODAY () ), MONTH ( TODAY () ), 1 )
VAR LastDayOfMonth =
    EOMONTH ( TODAY (), 0 )
RETURN
    FILTER (
        Table,
        Table[List_Date] < FirstDayOfMonth
            && ( Table[Binding_Ag] >= FirstDayOfMonth
            && Table[Binding_Ag] <= LastDayOfMonth )
            || ( Table[Expiration date] >= FirstDayOfMonth
            && Table[Expiration date] <= LastDayOfMonth )
            || Table[Expiration date] = BLANK ()
    )

Regards,

 

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.