I am connecting PBI to Snowflake using DirectQuery. To keep it simple, I have two tables, a product dimension table and a sales fact table. There are 3.7M rows in the product dimension table and 100M in the sales fact table. I also have a measure that calculates total sales which uses SUM to sum a column in the fact table.
I create a table visual in PBI and put the product description as the first column. The query generated by PBI is good. It retrieves 501 rows and displays them. So far, so good. Next I put the total sales measure as the second column. Now PBI generates several queries retrieving 1,000,001 rows. Of course I get an error stating the 1M row limit for DirectQuery has been reached.
This should not be happening. Has anyone run into something like this? Is there anything I can do?
I had a dig around and there is a capability to adjust the limit if you have a premium license
https://powerbi.microsoft.com/en-gb/blog/five-new-power-bi-premium-capacity-settings-is-available-on-the-portal-preloaded-with-default-values-admin-can-review-and-override-the-defaults-with-their-preference-to-better-fence-their-capacity/
Related
I have a dataset:
If I were to create a payment inflow matrix per a cohort where payment created_date is in columns and created date formatted as a cohort is in rows, it will look like:
I need to calculate running total per a column - see below:
There could be other fields in the table, e.g. product type which should influence running total.
I've seen the standard solution with = calculate(sum([X]), all(table), [date]<=max[date]) but I cannot make it work. What am I doing wrong? .pbix is uploaded at https://drive.google.com/file/d/1E3qJyOv11xSOlVRHAL9uq2C1Zho-g3zc/view?usp=sharing
You can use one of Power BI's build-in Quick measures:
This will give you the following result:
However, you won't get any aggregation for Jan and Feb since there are no according records in 2022-2. It looks like created_q is actually order_q?
When this is important, you would have to add dummy zero amounts with 2022-2 order_date.
I'm very stuck and I was hoping you can help. So have the following dataset (Table 1) with Month (5 years worth), Customer (1000 customers), Product (100 products), Units and Value (value is just unit multiple a price). The data only shows rows with unit and value, so for customers when there is no sale in a month, there is no data.
Click here for Table 1
I want to create a table (Table 2) where every product for every customer is shown for all time periods, where actual units and values are included and those missing in Table 1 are now showing 0.
Click here for Table 2
I have read many posts here and elsewhere, which only handles 1 column (e.g. only Customer not both Customer AND Product, and only 1 measure not Unit and Value). I tried to adapt the code but failed miserably.
I also want to do this in Power BI using M not DAX, because I would like to further transform the data.
Thank you so much everyone!!!
Good afternoon.
You can use DAX to create a calendar for the required period of time.
Use the minimum and maximum values from Table 1 for the interval (Calendar function).
Calendar = CALENDAR(Date(2022,5,1), TODAY() -1)
Link the calendar to the necessary dates.
calendar link example
In the settings of the table to which you will output data, select the "Show items without data" setting, and take the date from the calendar.
I know similarly named topics exist but I spent hours looking for the answer to something which i feel must be easy to do.
I have a table Visual in Power Bi and need to get a row count which would adjust as users set filters and use slicers.
The columns in the table don't have one level of hierarchy (otherwise a measure with DISTINCTCOUNT would do the trick), see an image of my table - I need to count rows in this table (21).
I couldn't find any way to directly refer to the Table Visual in DAX so simple COUNTROWS() wasn't useful. I tried to create a measure using various DAX expressions i found, e.g. recreate the table in DAX using CALCULATETABLE and have it use active filters, i failed there...
I also created an index variable on the physical/dataset table and tried to add it to the visual table and summarize it in some way (the column "Counter" in the table) - it didn't work, didn't give me the number of rows in the visual table but gave the number of rows in the physical/database table.
Please could you help me how to do this...
You won't really be able to access the table visual in the way you're thinking, but as long as you know how it comes together, that should be just as good.
CountSummaryRows =
CALCULATE(
COUNTROWS(SUMMARIZE(Table1, Table1[A], Table1[B], Table1[C], Table1[D])),
ALL(Table1)
)
This measure will aggregate to the level of your A,B,C,D columns, then count the total. ALL(Table1) just ensures you get the grand total, so every row should show as 21, but at least you'll have a handle on that summary table count.
I have two tables from Azure SQL in PowerBI, using direct query:
EMP(empID PK)
contactInfo(contactID PK, empID FK, contactDetail)
which have an obvious one-to-many relationship from EMP.empID to contactInfo.empID. The foreign key constraint is successfully enforced.
However I can only create a many-to-one relationship (contactInfo.empID to EMP.empID) in PowerBI. If I ever try the opposite, PowerBI always automatically converts the relationship to many-to-one (by swapping the from and to column), which prevents me from creating visuals. Does PowerBI think the two are equivalent?
Update:
What I'm doing is to just create a table in PowerBI showing the join results of these two tables. The foreign key constraint is contactInfo.empID REFERENCES EMP.empID, which is many-to-one. That should not be a problem, I guess, since I can directly query the join using SQL.
Please also suggest if I should create the foreign key in the opposite direction.
More info on failure to create visual
The exact error message is:
Can't display the data because Power BI can't determine
the relationship between two or more fields.
Version: 2.43.4647.541 (PBIDesktop)
To reproduce the error:
DB schema is as follows:
What I want is a table in PowerBI showing contact and sales info of am employee, that is, joining all the four tables. The error will occur when VALUES of the table visual contains "empName, contactDetail, contactType, productName", however, error will NOT occur if I only include "empName, contactDetail, contactType" or "empName, productName". At first I thought the problem may lie in the relationship between contactInfo and emp, but it now seems to be more complicated. I guess it may be caused by multiple one-to-many relationships?
Expanding my comments to make an answer:
Root of the Problem
In your data model, a single employee can have multiple contacts and multiple sales. But, there's no way for Power BI to know which contactDetail corresponds to which productName, or vice versa (which it needs to know to display them together in a table).
Deeper Explanation
Let's say you have 1 emp row, that joins to 10 rows in the sales table, and 13 rows in the contactInfo table. In SQL, if you start from the emp row and outer join to the other 2 tables, you'll get back (1*10)*(1*13) rows (130 rows in total). Each row in the contactInfo table is repeated for each row in the sales table.
That repetition can be a problem if you do something like sum the sales and don't realize a single sales record is repeated 13 times but might be fine otherwise (e.g. if you just want a list of sales and all associated contacts).
Power BI vs. SQL
Power BI works slightly differently. Power BI is designed primarily to aggregate numbers, and then break them down by different attributes. E.g. sales by product. Sales by contact. Sales by day. In order to do this, Power BI needs to know 100% how to divide numbers up between the attributes on your table.
At this point, I'll note that your database diagram doesn't include any obvious metrics that you'd use Power BI to aggregate. However, Power BI doesn't know that. It behaves the same whether you have metrics to aggregate or not. (And failing all else, Power BI can always count your rows to make a metric.)
Let's say that you have a metric on your sales table called Amt Sold. If you bring in the empName, productName, and Amt Sold columns, Power BI will know exactly how to divide up Amt Sold between empName and ProductName. There's no problem.
Now add in contactDetail. Using your database diagram, Power BI has no way of knowing how an Amt Sold metric in the sales table relates to a given contactDetail. It might know that $100 belongs to empID 27. And that empID 27 corresponds to 3 records in the contactInfo table. But it has no way of knowing how to divide up the $100 between those 3 contacts.
In SQL, what you'd get is 3 contacts, each showing the $100 amount sold. But in Power BI, that would imply $300 was sold, which isn't the case. Even equally dividing the $100 up would be misleading. What if the $100 belonged entirely to 1 contact? So instead, Power BI shows the error you're seeing.
My Recommendations
If you can, I recommend changing your data model before your bring it in. Power BI works best with a single fact table, which would contain your metrics (like amount sold). You then join this fact table to as many lookup tables as you like (e.g. customer, product, etc.), directly. This allows you to slice & dice your metrics with any combination of attributes from any of the lookup tables. I would recommend checking out the star schema data model and the concept of lookup tables: powerpivotpro.com/2016/02/data-modeling-power-pivot-power-bi
At the very least, you would want to flatten your tables (i.e. merge the contactInfo and sales tables into a single table before importing them into your data model.
It may be that Power BI isn't the best tool for what you're trying to accomplish. If all you want is a table showing all sales & contact info for an employee, without any associated metrics, a regular reporting tool + SQL query might be a better way to go.
Side Note: You can't reverse a many:one relationship to get past this error. The emp table contains one row per empID. Both the contactInfo and sales tables contain multiple rows with the same empID. This means the emp table is necessarily the "one" side of the relationship to both those tables. You can't arbitrarily change that.
I'm struggling with what I assume is a calculated table in Power BI Desktop.
I need to somehow connect my database loaded Accounts table with a manually created Progress table (with some fixed data), so that each row in Accounts basically has a calculated column which is the resulting Progress table for that row. (Hope that makes sense).
[This is the Progress table1
The calculated columns in the Progress table should use data from the related Accounts row to give an overview of where the Account is now, how long it took and the likely future time frames to reach the next levels of progress.
Is there a way to do such a thing?
TIA!
Dennis
I think you have 2 options:
Add a column in the model layer using the DAX LOOKUPVALUE function: https://msdn.microsoft.com/en-us/library/gg492170.aspx
From the Edit Queries window, use the Merge Queries button, then Expand the resulting NewColumn.