web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Date filter against a ...
Power Automate
Unanswered

Date filter against a dataset in Power BI is not filtering Properly

(0) ShareShare
ReportReport
Posted on by 9

Hi all,

 

I am trying to filter the table by date value to show only last 4 days of data and trying to compose into a HTML table but it does not filter or retrun the data properly.

 

For example, todays date is 28/05/2024 and if I run the query to filter and return last 4 days, expected output to return data for 25,26,27 and 28 (include today). But it return the data only for 28th May 2024.


Here is the DAX query that is used to run against the dataset, VAR __DS0FilterTable2 :

 

 

// DAX Query
DEFINE
	VAR __DS0FilterTable = 
		TREATAS({"White/Yellow"}, 'PotatoPackoutMainlines'[Variety])

	VAR __DS0FilterTable2 = 
		FILTER(
			KEEPFILTERS(VALUES('Calendar'[DateValue])),
			AND(
				'Calendar'[DateValue] >= TODAY() - 4,
				'Calendar'[DateValue] = TODAY()
			)
		)

	VAR __ValueFilterDM3 = 
		FILTER(
			KEEPFILTERS(
				SUMMARIZECOLUMNS(
					'Calendar'[DateValue],
					'PotatoPackoutMainlines'[ProductionArea],
					'PotatoPackoutMainlines'[AM/PM],
					__DS0FilterTable,
					__DS0FilterTable2,
					"SumTonnesDelivered", CALCULATE(SUM('PotatoPackoutMainlines'[TonnesDelivered])),
					"SumTonnesTipped", CALCULATE(SUM('PotatoPackoutMainlines'[TonnesTipped])),
					"SumTonnesPacked", CALCULATE(SUM('PotatoPackoutMainlines'[TonnesPacked])),
					"v__Total_Waste2", 'PotatoPackoutMainlines'[# Total Waste],
					"SumPacked_Premium", CALCULATE(SUM('PotatoPackoutMainlines'[Packed_Premium])),
					"v__Total_Waste", 'PotatoPackoutMainlines'[% Total Waste],
					"v__Premium_Packed", 'PotatoPackoutMainlines'[% Premium Packed],
					"v__Diff__PD_v2", IGNORE('PotatoPackoutMainlines'[# Diff. PD v2])
				)
			),
			NOT(ISBLANK([v__Diff__PD_v2]))
		)

	VAR __DS0Core = 
		SUMMARIZECOLUMNS(
			ROLLUPADDISSUBTOTAL(
				ROLLUPGROUP(
					'Calendar'[DateValue],
					'PotatoPackoutMainlines'[ProductionArea],
					'PotatoPackoutMainlines'[AM/PM]
				), "IsGrandTotalRowTotal"
			),
			__DS0FilterTable,
			__DS0FilterTable2,
			__ValueFilterDM3,
			"SumTonnesDelivered", CALCULATE(SUM('PotatoPackoutMainlines'[TonnesDelivered])),
			"SumTonnesTipped", CALCULATE(SUM('PotatoPackoutMainlines'[TonnesTipped])),
			"SumTonnesPacked", FORMAT(CALCULATE(SUM('PotatoPackoutMainlines'[TonnesPacked])),"#0"),
			"v__Total_Waste2", FORMAT('PotatoPackoutMainlines'[# Total Waste],"#0"),
			"SumPacked_Premium", FORMAT(CALCULATE(SUM('PotatoPackoutMainlines'[Packed_Premium])),"#0"),
			"v__Total_Waste", FORMAT('PotatoPackoutMainlines'[% Total Waste],"#0.00%"),
			"v__Premium_Packed", FORMAT('PotatoPackoutMainlines'[% Premium Packed],"#0.00%")
		)

	VAR __DS0PrimaryWindowed = 
		TOPN(
			501,
			__DS0Core,
			[IsGrandTotalRowTotal],
			1,
			'Calendar'[DateValue],
			1,
			'PotatoPackoutMainlines'[ProductionArea],
			1,
			'PotatoPackoutMainlines'[AM/PM],
			1
		)

EVALUATE
	__DS0PrimaryWindowed

ORDER BY
	[IsGrandTotalRowTotal],
	FORMAT('Calendar'[DateValue],"yyyy-MM-dd"),
	'PotatoPackoutMainlines'[ProductionArea],
	'PotatoPackoutMainlines'[AM/PM]

 

 Attached image is the output image.

 
How should I resolve this ? Is there any other way of writing the date filter query?

Thanks for the help in advance!

Date filter output.png
Categories:
I have the same question (0)
  • ricpower00 Profile Picture
    42 on at

    It looks like your date logics are contradicting, and you need to remove the second condition

    	VAR __DS0FilterTable2 = 
    		FILTER(
    			KEEPFILTERS(VALUES('Calendar'[DateValue])),
    			AND(
    				'Calendar'[DateValue] >= TODAY() - 4,
    				'Calendar'[DateValue] = TODAY()
    			)
    		)

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 283

#2
David_MA Profile Picture

David_MA 256 Super User 2026 Season 1

#3
Expiscornovus Profile Picture

Expiscornovus 225 Most Valuable Professional

Last 30 days Overall leaderboard