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
khush19
Resolver I
Resolver I

Cosmos DB to PowerBI connection

I have a requirement where i need to Use COSMOS DB to get the current and historica data to POWERBI

 

  1. How to write query in POWER BI to get like today data or last week data comparing mt date field in COSMOS DB?
  2. What I uderstood is as powerBI support only IMPORT fuctionality to COSMOS DB,and we can schedule refresh after every hour which is minimum,My PowerBI report will get embedded to POWERBI embedded .
    •  Is is possible that every time I Load/reload  my page then powerBI should query COSMOS Db and get updated data and if the user is on same page for more than a hour the page get refreshed ,by the latest data through schedule refresh.
  3. I am POWERBI pro licence user,I read that I can schedule refresh ,where minimum is hourly for import,https://community.powerbi.com/t5/Service/Azure-DocumentDB-and-slow-refresh/m-p/47940#M10390 BUT when i see on my POWER BI service,I can see only Daily ,weekly ..no Hourly 
1 ACCEPTED SOLUTION

hi @khush19 

Yes, you could try this way as below:

Step1:

In Edit Queries, add a days-between column as below:

DateTime.LocalNow()-[OrderDate]

1.JPG

Step2:

Change the datatype to decimal number

2.JPG

Step3:

Now add a conditional column as below:

if [Days difference]>=0 and [Days difference]<=1 then "last days" else "Not last day"

Note:This is my simple sample data, For your case, just use 7 instead of 1.

 

3.JPG

Step3:

Filter this column which is "Last days"

Step4(optional):

remove these new columns.

 

and here is my simple sample pbix file, please try it.

 

Regards,

Lin

 

 

Community Support Team _ Lin
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-lili6-msft
Community Support
Community Support

hi @khush19 

1. You could write custom SQL code to get data or use custom filter in edit queries

8.JPG

9.JPG

 

2. You could set schedule refresh for datasetdataset will Load/reload data from datasource. The reports refresh data cache from dataset.

3. For pro licence user, they can schedule refresh 8 times a day at most, You could choose daily or weekly, then choose 8 time points at most for refresh.

11.JPG12.JPG

Regards,

Lin

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

Thanks Lin,

 

In COSMOSDB is it possible to get lastweek data will current TIME.

I hav documents present in COSMOS DB ,in that Document I have JSON Array structure

Order{

"Amount":$10,

"OrderDate"="2019-11-15 10:55:49.000"

          }

 

So i need sum for today and also sum for last week same day till current time:

So if today is 15/11 2:36 pm

So i need Amount for today till 2:56 and also amout for 08/11 till 2.56,is this possibe?

hi @khush19 

Yes, you could try this way as below:

Step1:

In Edit Queries, add a days-between column as below:

DateTime.LocalNow()-[OrderDate]

1.JPG

Step2:

Change the datatype to decimal number

2.JPG

Step3:

Now add a conditional column as below:

if [Days difference]>=0 and [Days difference]<=1 then "last days" else "Not last day"

Note:This is my simple sample data, For your case, just use 7 instead of 1.

 

3.JPG

Step3:

Filter this column which is "Last days"

Step4(optional):

remove these new columns.

 

and here is my simple sample pbix file, please try it.

 

Regards,

Lin

 

 

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

Hi Lin,

 

Just a quick question ,I tried to get sum or any Aggregate function in COSMOSDB through POWERBI,but it always give me error:

The field "errors" of record was not found.

 

Can we perform the aggregation in powerbi for COSMOS?

 

and as you mentioned edit in Edit query mode,so  when i edit in POWERBI to give me today data ,it takes a long time to filter because it has loaded all the document and then filtering on that.

 

can we write something like getdate() in sql query..where orderdate=getdate() in powerbi for cosmos and also get last week data through writing query?

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.