cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
PBIDataNerd
New Member

Filter Table by Selected Quarter (mindate / maxdate)

Hi 

 

Am trying to create a calculated table with filter on selected dates (Quarter mindate and maxdate).

 

PBIDataNerd_0-1638827985273.png

and my DAX is as follows:  

 

filteredbyQtr =
VAR mindate =
    MIN ( 'Date'[Date] )
VAR maxdate =
    MAX ( 'Date'[Date] )
VAR result =
    CALCULATETABLE (
        Sales,
        FILTER ( sales, Sales[SaleDate] >= mindate && Sales[SaleDate] <= maxdate )
    )
RETURN
    result

 

But seems this doesnt work... always returns full records.  

 

1 ACCEPTED SOLUTION
V-lianl-msft
Community Support
Community Support

Hi @PBIDataNerd ,

 

Tables and columns in PBI are ALWAYS STATIC.They're recalculated when data is refreshed. 

Measures are dynamic and the value will change with slicer or other filtering methods.

You can try to apply the following measure =1 in the visual level filter as workaround:

filteredbyQtr =
VAR mindate =
    MIN ( 'Date'[Date] )
VAR maxdate =
    MAX ( 'Date'[Date] )
RETURN
    IF(MAX('SALES'[SaleDate])>=mindate &&MAX('SALES'[SaleDate])<=maxdate,1,0)


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

View solution in original post

4 REPLIES 4
V-lianl-msft
Community Support
Community Support

Hi @PBIDataNerd ,

 

Tables and columns in PBI are ALWAYS STATIC.They're recalculated when data is refreshed. 

Measures are dynamic and the value will change with slicer or other filtering methods.

You can try to apply the following measure =1 in the visual level filter as workaround:

filteredbyQtr =
VAR mindate =
    MIN ( 'Date'[Date] )
VAR maxdate =
    MAX ( 'Date'[Date] )
RETURN
    IF(MAX('SALES'[SaleDate])>=mindate &&MAX('SALES'[SaleDate])<=maxdate,1,0)


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

amitchandak
Super User
Super User

@PBIDataNerd , You can not use Slicer values in a new calculated table.



!! Microsoft Fabric !!
Microsoft Power BI Learning Resources, 2023 !!
Learn Power BI - Full Course with Dec-2022, with Window, Index, Offset, 100+ Topics !!
Did I answer your question? Mark my post as a solution! Appreciate your Kudos !! Proud to be a Super User! !!

hmm.. is there a way to just show only the dates which got sale and are within the selected quarter.

@PBIDataNerd , Only in visual tables using measures.

 

Variable using var in dax measure can have calculatedtable using slicer value 



!! Microsoft Fabric !!
Microsoft Power BI Learning Resources, 2023 !!
Learn Power BI - Full Course with Dec-2022, with Window, Index, Offset, 100+ Topics !!
Did I answer your question? Mark my post as a solution! Appreciate your Kudos !! Proud to be a Super User! !!

Helpful resources

Announcements
Exciting changes

Power BI Community Changes

Check out the changes to the Power BI Community announced at Build.

May 2023 update

Power BI May 2023 Update

Find out more about the May 2023 update.

Kudo Data Story carousel

Data Stories Gallery

Visit our Data Stories Gallery and give kudos to your favorite Data Stories.

Top Solution Authors