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
smpa01
Super User
Super User

How to run queries on each SSAS DBs

To better describe my issue, I am trying to do a mimimum reproducible example in very few words so that someone willing to resolve this can take the MRE and try this out.

Let's suppose I have two SSAS DBs, e.g. sales1 and sales2 which I have published in my workspace.

 

 

 

SSAS model called sales1
| Calendar 	Table 	|

| Year 	|  	
| 2018 	|  	
| 2019 	|  	

| Fact 	Table  	|

| Year 	| Val 	|
| 2018 	| 1000 	|
| 2018 	| 2000 	|
| 2019 	| 3000 	|
| 2019 	| 4000 	|

| Measure 	Table 	|
Sales = SUMX('_sales1','_sales1'[Val])
------------------------

SSAS model called sales2
| Calendar 	Table 	|

| Year 	|  	
| 2020 	|  	
| 2021 	|  	

| Fact 	Table  	|

| Year 	| Val 	|
| 2020 	| 5000 	|
| 2020 	| 6000 	|
| 2021 	| 7000 	|
| 2021 	| 8000 	|

| Measure 	Table 	|
Sales = SUMX('_sales2','_sales2'[Val])

 

 

 

Capture.PNG

I want to create a seperate dataset by running a SSAS query dynamically on each sales DB, e.g. which takes the SSAS DB name as parameter and returns the result against each DB.

 

 

 

SUMMARIZECOLUMNS('Calendar'[Year],"sales",[Sales])

 

 

 

 

 

let
    Source = AnalysisServices.Databases("powerbi://api.powerbi.com/v1.0/myorg/PBI Workspace", [Implementation="2.0"])[Name],
    #"Converted to Table" = Table.FromList(Source, null,{"Name"}),
    #"Filtered Rows" = Table.SelectRows(#"Converted to Table", each Text.StartsWith([Name], "sales")),
/*pass on DB name as parameter to SSAS*/
	#"Added Custom" = Table.AddColumn(#"Filtered Rows", "Custom", each AnalysisServices.Database("powerbi://api.powerbi.com/v1.0/myorg/PBI Workspace", ""&[Name]&"",[Query="EVALUATE SUMMARIZECOLUMNS('Calendar'[Year],""sales"",[Sales])", Implementation="2.0"])),
#"Removed Other Columns" = Table.SelectColumns(#"Added Custom",{"Custom"}),
    #"Expanded Custom" = Table.ExpandTableColumn(#"Removed Other Columns", "Custom", {"Year", "sales"}, {"Year", "sales"})
in
    #"Expanded Custom"

 

 

 

The query runs fine but when I publish this dataset back to workspace I get the following error.

Capture.PNG

@ lbendlin previously looked into it and suggested that it might be a live connection and data would always be live. But I have verified that and can confirm that the data is not live at all and since the schedule can't be refresehed, it contains stale data.

 

I have also tried to convert this into a dataflow and it does not work either. Is there any workaround to this? I am trying to avoid the situtation where I have to manually select each SSAS DBs and run the query manually on each of them.

 

Thank you in advance and sorry for the long post.

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
8 REPLIES 8
v-xulin-mstf
Community Support
Community Support

Hi @smpa01,

 

Please refer to the following post about the same error message and follow the steps it mentions to check.

https://community.powerbi.com/t5/Desktop/Data-sources-don-t-support-refresh/td-p/267155

If you still have some question, please don't hesitate to let me known.‌‌

 

Best Regards,

Link

 

Is that the answer you're looking for? If this post helps, then please consider Accept it as the solution. Really appreciate!

@v-xulin-mstf  thanks for looking into it and what I have gathered from the post that either Enabling "Include in report refresh" or Disabling "Include in report refresh" might fix the problem. I tried both, yet I see the following in each instances

Capture.PNG

 

Additionally I see the following in my Data Source Settings.

Recap:- I am trying to run a SSAS qury on each of my SSAS DBs(DB name starts with sales) and pass on the name of the DB as query parameter on each SSAS query.

 

Capture.PNG

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

Hi @smpa01,

 

Is your issue solved? If the issue has been solved, please adopt the solution to help others.

If you still have some question, please don't hesitate to let me known.‌‌

 

Best Regards,

Link

 

Is that the answer you're looking for? If this post helps, then please consider Accept it as the solution. Really appreciate!

@v-xulin-mstf  please hold on, it has not resolved my issue. I am going to discuss this in a call with MS.

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

Hi @smpa01,

 

How did you get the datasource?

From your screenshot, we know that you called an API interface, please check if this API interface successfully accesses the data source.

Based on my test, you can manage parameters in power query to meet your need.

vxulinmstf_0-1627965126101.pngvxulinmstf_1-1627965130277.pngvxulinmstf_2-1627965139095.png

In addition, please refer this troubleshooting to compare your datasource with the list of supported data sources found in Power BI data sources.

If you still have some question, please don't hesitate to let me known.‌‌

 

Best Regards,

Link

 

Is that the answer you're looking for? If this post helps, then please consider Accept it as the solution. Really appreciate!

GilbertQ
Super User
Super User

Hi @smpa01 

 

Why not use a composite model where you bring in both datasets into a single PBIX?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!







Power BI Blog

@GilbertQ  thanks for looking into it. The suggestion of bringing theses sales DBs as composite models does not solve my purpose. In reality there are nth number of sales DBs (sales1, sales2, ...sales35,salesn) which keeps on compounding. If I rely on bringing them as composite model, I need to keep on manually adding each DB in the composite model for each nth SSAS sales DB gets added in the workspace. I want to avoid that. I can utilize power query to my rescue for this which works beautifully but does not refresh on the workspace that defeats the purpose.

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

Hi @smpa01 


What happens if you had to try and just connect via Analysis Services and put in the Query at the start. Then merge / append the tables later in PQ?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!







Power BI Blog

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.

Top Solution Authors
Top Kudoed Authors