I am trying to create a % of sales measure in power bi. I currently have a visual that is filtered on sales for select items by day and another visual that just has the total sales by day and then I export and do the math in excel. I know there is a way to have just one visual give me the % of sales for the items I have selected, but can't figure out the DAX formula. I am looking for the formula that will take sales for item 1 on Monday of $3,461 and divide by total sales for Monday of $163,534 to get a 2.1% of sales (for all items). Thanks
Power Bi Visuals
I tried a couple formulas but was unsuccessful..
The December release of PBI has been pushed out to all users, and it comes with a brand-new WINDOW function. This allows you to create calculations that would be relative to data being displayed in the visualization rather than applying across an entire table.
Some things you can do with this type of DAX calculation:
Moving averages
Can also combine with parameters for additional functionality!
Dynamic reference lines
Cross row calculations
Finding best and worst performers (with ABS references)
Calculate contributions to the whole
Relevant links:
https://www.youtube.com/watch?v=eib5X5xRlz8
Introducing DAX Window Functions (Part 1) – pbidax (wordpress.com)
WINDOW – DAX Guide
Related
I have a "strange" problem in visualizing the values of the "last" year (that is the most current year with data of a full year). In the example delivered it is 2019 which holds the bookings facts. The year should be derived by a related table (LetztesVollesJahrDim) that holds a min/max date and year value for each company/entity. The DateDim table holds all dates and is configured to be the Date dimension.
The relations are shown in the graphic below.
I created a Report that should display different matrix tables with different values:
one, that shows the last full year's monthly values by Cost Center (which works correct)
one, that shows all years monthly values including an estimated value for the current year (2020) (which also works correct)
one, that could drill down to the details level of the Facts and display the figures per month (in columns) of the last full year (i.e. 2019) putting the Cost Center and other groups down the most detailed level into rows. This Matrix makes use of Calculated Measures created with Tabular Editor.
At this point I can here you say... try it without the Calculated measures and indeed I did that by simply displaying a Card that got a Visual Filter to DateDim[M]=7 to simulate the appliance of each matrix's column. Problem is the same: The Month filter of the Visual (or within the Calculated Measure) is ignored and the yearly sum is displayed (~48k) which is wrong.
As I am currently an Expert in SQL Server DBMS but not in the Architecture of Power BI's DAX Models I am not truely aware about the consequences when and why filters are removed, ignored, overwritten or added at which level of modeling.
Originally I tried to create a simple Calculated Measure that reflects the last full year of the company. That works, but its usage in the huge Matrix was impossible as it was calculating forever. That's why I created the simple table "LetztesVollesJahrDim" to hold a persisted value for each company.
The idea is simple: Create a Query that inner joins these tables and display the Sum for each month [M] like this:
Fact[Turnover] - Fact[CompanyKey] -> CompanyDim[CompanyKey] <-> LastFullYear[CompanyKey] - LastFullYear[MostCurrentYear] -> DateDim[Y] - DateDim[DateKey] -> Fact[StapleDateKey]
So, what is the Problem?
I tried a couple of DAX queries and all come up with a different wrong value.
Following three different approaches for a Calculated Measure "Sum LY":
1.
Σ LY = CALCULATE(SUM(KontobuchungenFact[UmsatzNegiert]), DATESBETWEEN(DateDim[DateKey], DATE(2019, 1, 1), DATE(2019, 12,31)))
2.
Σ LY = CALCULATE(SUM(KontobuchungenFact[UmsatzNegiert]), SAMEPERIODLASTYEAR(DateDim[DateKey]))
[
3.
Σ LY = CALCULATE(SUM(KontobuchungenFact[UmsatzNegiert]), KEEPFILTERS(DateDim[M]), USERELATIONSHIP(DateDim[J], LetztesVollesJahrDim[AktuellstesJahr]), USERELATIONSHIP(DateDim[DateKey], KontobuchungenFact[StapelDateKey]))
Filters being applied on the page/visual:
CompanyKey
DateKey >= 2018-01-01 (page filter that limits the displayed rows in yearly matrix to the last 3 ys)
Some other irrelevant keys
Visual configuration:
Relations:
Values/Rows in the LetztesVollesJahrDim table:
Calculated Measures/Table in Tabular Editor showing the calculation of the "01 Jan" column of the first Matrix, which displays correct results:
Impression of the Report:
So in summary I need a clue/DAX formula that recognizes the Monthes in each column and ideally uses the relations to the last year table trespassing the year's filter through DateDim to the Facts.
It is funny, that the upper matrix works, but not the one on the bottom. It is not possible to use the calculated measures approach of the first matrix in the last matrix because the performance would drop to > minutes calculation. So I cannot use the same approach and need a fast one.
Anybody an idea? :-)
I've sifted through threads and videos trying examples, but I still seem to be stuck. Please help? DAX newbie here.
I have a data set with yearly sales with granularity by geography, device type, and another column with ~6 different technical specifications. I would like to display a dynamic waterfall chart that shows yearly changes in sales based on selected slicers/filters in the workbook.
1) Resolve in one step
=CALCULATE(SUM(Data[$]))-CALCULATE(SUM(Data[$]),PARALLELPERIOD(Data[Date],-1,YEAR))
2) Create an intermediate value for last year sales and subtract from this year's sales
LY Sales = CALCULATE(SUM(Data[$]),DATEADD(Data[Date],-1,YEAR))
VARIANCE = [$] - [LY Sales]
I am looking to calculate
'supplier = (sum of group 1 x weighting) + (sum of group 2 x weighting).
In excel I use 2 tables to calculate, but struggling to figure this out in powerbi so far
I am currently using PowerBi to create Averages of scores per supplier.
I am now trying to moved towards weighted totals and weighted averages.
In my scenario I have
8 Divisions
22 Groups (of suppliers ie. Joint Ventures, multiple Suppliers working on a contract)
8 Individual Suppliers made up of a percentage of a group of suppliers.
Within Excel, I have created a supplier list 1-8 which uses a sum if from another table.
SUMIFS('Group Totals (Per)'!F:F,'Group Totals (Per)'!$B:$B,$B2)
This other table is a sumif of group name, division multiplied by weighting (percentage of the contract)
=SUM(SUMIFS(Payments!$I:$I,Payments!$C:$C,'Group Totals'!$A7,Payments!$B:$B,'Group Totals'!F$1)*$C7)
My hope is to replicate this within power BI.
So I can click select a supplier and see the total payments received (which will be a sum of a percentage of the group contract (joint ventures).
However I have been unable to separate out the suppliers totals with weighting, after creating links tables.
I have supplied sample data in excel and power BI and screenshots.
Here's a link! to the files.
SUMX is similar to SUMIF in Excel. But I would recommend you using CALCULATE function which gives you lot of options. A simple google will give you a lot of tutorials on how to use it.
I am building Analytical solution and need to calculate - Average Number of Users accessed reports per day in Power BI (DAX)
The best way I think is to add a Measure Right click on table > Add measure:
'MesaureAvg
AVERAGE('YourTableName'[ColumnName])
Then put in a visual in your PowerBI report with MeasureAvg and the Date column.
let's say I have a KPI which is a simple calculation like
SUMX(FILTER(Table;Table[Date] < Today());Table[Column])
I would like to plot a time series of the KPI's past values (for example for the first day of every month since 01-01-2014), so for instance it is enough to create a new table - Trend_Table - with two columns - DATE, KPI and calculate each row's KPI value as
SUMX(FILTER(Table;Table[Date] < Trend_Table[Date]);Table[Column])
(it may not exactly work that way in DAX but you get the idea)
The problem is I really want to have online values, which means that once the September begins a new row with DATE = '01-09-2018' should be added automatically to the table 'Tren_Table'.
Is it possible in Power BI? Any referalls greatly welcomed.