I have an Olap cube which contains one measure Sales. Then I have a dimension called Version Type containing the values "Actual", "Budget", etc.
| MeasureType | Sales |
|-------------|-------|
| Actual | 900 |
| Budget | 1000 |
When I try and use a Gauge in PowerBI i put my measure Sales into the Value and Target, but i can't say "Sales measure filtered by Actual" and "Sales measure filtered by Budget".
Is this possible? Do I have to create distinct measures to use this tool?
Related
how to aggregate the sells by date i want to know the total of sells for each day
|DATE | SELLS |
|2022-01-27 |48$ |
|2022-01-27 | 25$ |
|2022-01-27 | 150$ |
|2022-01-25 | 55$ |
no idea about the query
perhaps i should creat an other table which hold only total sells per day
Do a GROUP BY
select date, sum(sells)
from tablename
group by date
(No need for another table. Such copying of data too often leads to data inconsistency.)
I'm trying to calculate a business-logic in DAX which has turned out to be quite resource-heavy and complex. I have a very large PowerPivot model (call it "sales") with numerous dimensions and measures. A simplified view of the sales model:
+-------+--------+---------+------+---------+-------+
| State | City | Store | Week | Product | Sales |
+-------+--------+---------+------+---------+-------+
| NY | NYC | Charlie | 1 | A | $5 |
| MA | Boston | Bravo | 2 | B | $10 |
| - | D.C. | Delta | 1 | A | $20 |
+-------+--------+---------+------+---------+-------+
Essentially what I'm trying to do is calculate a DISTINCTCOUNT of product by store and week:
SUMMARIZE(Sales,[Store],[Week],"Distinct Products",DISTINCTCOUNT([Product]))
+---------+------+-------------------+
| Store | Week | Distinct Products |
+---------+------+-------------------+
| Charlie | 1 | 15 |
| Charlie | 2 | 7 |
| Charlie | 3 | 12 |
| Bravo | 1 | 20 |
| Bravo | 2 | 14 |
| Bravo | 3 | 22 |
+---------+------+-------------------+
I then want to calculate the AVERAGE of these Distinct Products at the store level. The way I approached this was by taking the previous calculation, and running a SUMX on top of it and dividing it by distinct weeks:
SUMX(
SUMMARIZE(Sales,[Store],[Week],"Distinct Products",DISTINCTCOUNT([Product]))
,[Distinct Products]
) / DISTINCTCOUNT([Week])
+---------+------------------+
| Store | Average Products |
+---------+------------------+
| Charlie | 11.3 |
| Bravo | 18.7 |
+---------+------------------+
I stored this calculation in a measure and it worked well when the dataset was smaller. But now the dataset is so huge that when I try to use the measure, it hangs until I have to cancel the process.
Is there a more efficient way to do this?
SUMX is appropriate in this case since you want the distinct product count calculated independently for each store & for each week, then summed together by store, and then divided by the number of weeks by store. There's no way around that. (If there was, I'd recommend it.)
However, SUMX is an iterator, and so is the likely cause of the slowdown. Since we can't eliminate the SUMX entirely, the biggest factor here is the number of combinations of stores/weeks that you have.
To confirm if the number of combinations of stores/weeks is the source of the slowdown, try filtering or removing 50% from a copy of your data model and see if that speeds things up. If that doesn't time out, add more back in to get a sense of how many combinations are the failing point.
To make things faster with the full dataset:
You may be able to filter to a subset of stores/weeks in your pivot table, before dragging on the measure. This will typically get faster results than dragging on the measure first, then adding filters. (This isn't really a change to your measure, but more of a behaviour change for users of your model).
You might want to consider grouping at a higher level than week (e.g. month), to reduce the number of combinations it has to iterate over
If you're running Excel 32-bit, or only have 4GB of RAM, consider 64-bit Excel and/or a more powerful machine (I doubt this is the case, but am including for comprehensiveness - Power Pivot can be a resource hog)
If you can move your model to Power BI Desktop (I don't believe Calculated Tables are supported in Power Pivot), you could extract out the SUMMARIZE into a calculated table, and then re-write your measure to reference that calculated table instead. This reduces the number of calculations the measure has to perform at run-time, as all the combinations of store/week plus the distinct count of products will be pre-calculated (leaving only the summing & division for your measure to do - a lot less work).
.
Calculated Table =
SUMMARIZE (
Sales,
[Store],
[Week],
"Distinct Products", DISTINCTCOUNT ( Sales[Product] )
)
Note: The calculated table code above is rudimentary and is mostly designed as a proof of concept. If this is the path you take, you'll want to make sure you have a separate store dimension to join the calculated table to, as this won't join to the source table directly
Measure Using Calc Table =
SUMX (
'Calculated Table',
[Distinct Products] / DISTINCTCOUNT ( 'Calculated Table'[Week] )
)
Jason Thomas has a great post on calculated tables and when they can come in useful here: http://sqljason.com/2015/09/my-thoughts-on-calculated-tables-in.html.
If you can't use calculated tables, but your data is coming from a database of some form, then you could do the same logic in SQL and then import a pre-prepared separate table of unique store/months and their distinct counts.
I hope some of this proves useful (or you've solved the problem another way).
I have a weird powerpivot that I'm hoping you experts could help...
The first table has agreementID and associating department, and the second table has agreementID and associating revenue (see below), I've also created a join between table1&table2 using agreementID. Currently I have a pivot table that shows the agreement ID and total revenue (all from the second table).
I created a department slicer from the first table. I was hoping this slicer would allow users to filter on the agreement based on the associating department (i.e. if "finance" is selected, only agreement 123/789 will show up).Right now, regardless of what I select in the slicer, all three agreements show up in the pivot.
Metric:=CALCULATE(SUM('Table2'[Revenue])
What am I doing wrong and how could I fix this issue?
would appreciate any help/support you can provide!
thank you,
Table 1
AgreementID | Department
========================
123 | Sales
123 | Finance
123 | Consulting
123 | Marketing
456 | Sales
456 | Consulting
456 | Marketing
789 | Sales
789 | Finance
789 | Marketing
Table 2
AgreementID | Revenue
=====================
123 | 900000
456 | 200000
789 | 400000
Metric:=
CALCULATE(
SUM(Table2[Revenue])
,Table1
)
You've got an abnormal table structure wherein your fact exists on the 1 side of a 1-many relationship. In DAX, you can force context to flow "uphill" from the many to the 1 by using a table reference in CALCULATE() from the many side of the relationship.
If using Power BI Desktop you can set a filter to be bi-directional and avoid having to write measures specially to deal with this situation. This will also be present in Tabular 2016, and therefore in Excel 2016.
You should also really give your tables better, more descriptive names than Table1 and Table2.
Below is an image showing everything in my model:
I created a table to keep track of shipments and the invoices associated with them. I'd prefer my table to be set up as below so that I can easily draw relations off of the invoice number column.
Shipment Table
``````````````
Field Name | Data Type
----------------+-------------
ID | Autonumber or Concat
Ship Date | Date
Shipper | List Lookup
Invoice Number | Text
Often times there are multiple invoices on one shipment ID, so in the form I would need the ID, Ship Date, and Shipper fields to be input for multiple Invoice Number records.
I'm not very handy with VBA, and the macro builder doesn't seem to be able to do what I want without going into VBA anyways. How would I tackle this using VBA?
Sample Data
```````````
ID | Ship Date | Shipper | Invoice Number
-------+--------------+---------+-----------------
13597 | 5/15/2015 | UPS | 230136
13597 | 5/15/2015 | UPS | 230137
13597 | 5/15/2015 | UPS | 230138
Form Design: http://i.stack.imgur.com/vyjLF.jpg
I need a report that has some data in it with calculation data among regular rows. For example:
Name | Age | Salary
HR | 35 | $1300
John | 30 | $1000
Mark | 40 | $1600
Law | 45 | $1500
Bill | 40 | $1000
Sara | 50 | $2000
The idea is to group rows by a field and then add a row with average numbers for this group.
Is it possible? I also have 2 date parameters (start and end), so I need to get all the records to SSRS and then filter them out...
Yes, this is possible and very straight forward.
Create your report with the data rows, then create a group on the Department field. You can do this a few ways: right click on the detail rows and select Add Group... or drag the department field to the Row groups pane in the design window.
Add a row to the group by right clicking on the details group and choosing to add a total, before the details. In the new row, set your formula to be =Avg(MyDataset!AgeFieldName.Value)
Take a look at the tutorials available on MSDN, especially the Grouping and Totals section