Pradeep
Pradeep

Reputation: 5510

How to write the queries in power bi

I am using Power BI in my current project for making charts. My data source is Azure SQL database.

I would like a table chart to display today and yesterday data only, for which i used advanced filtering by setting the filter to today and yesterday dates. However, I want to be able to open my report tomorrow and see charts use data from tomorrow and today respectively.

With advanced filtering the charts appear static, not dynamic.

It would be good if someone could explain how to write queries in Power BI on my tables.

Upvotes: 1

Views: 178

Answers (2)

Matt Mazzola
Matt Mazzola

Reputation: 5641

Using the SDK you can apply filter(s) dynamically to the report. This allows you to simulate the user filtering the report data to the current day and yesterday.

Your client app would compute the correct filter data values and apply it to the report. Using something like report.setFilters(filters)

See this related question for more information about filters: Power BI Embed URL-multiple filters

Upvotes: 0

user5226582
user5226582

Reputation: 1986

You could either

1) modify your sql query to only return today and yesterday data

or

2) add a calculated boolean column, something along the lines of

"IsCurrent = IF(AND(DATEVALUE(Table1[Date])<=TODAY() , 1.0*(DATEVALUE(Table1[Date])-TODAY())<=2),True,False)"

enter image description here

Then filter by IsCurrent.

Upvotes: 1

Related Questions