dax

DAX model invoice running balance

大兔子大兔子 提交于 2019-12-08 05:44:30
问题 I have a table with invoices and a table with payments. The Invoice table consists of invoice id, amount, invoice date, expiry date. The payment table consists of invoice id, amount, payment date. The invoice table have an active relationship with the date table on the expiry date column. The payment table have an active relationship with the invoice table on the invoice id columns. I would like to be able to show the invoice balance on an arbitrary day. Ie if I filter the report or page on a

Cant measure from date column

本秂侑毒 提交于 2019-12-08 01:50:31
问题 I'm trying to count days between a date from the column 'completionDate' and today The table name is 'Incidents (2)' I have a simuler table called 'incidents' here it's working. The code: DaysClosed = DATEDIFF('Incidents (2)'[completionDate].[Dag];TODAY();DAY) The error i get: 'A single value for variaton 'Dag' for column 'completionDate' in table 'Incidents (2)' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an

DAX measure with TOTALMTD running slow

心不动则不痛 提交于 2019-12-07 18:35:37
问题 I have two measures in my tabular cube. The first one called 'Number of Days' := CALCULATE(COUNTROWS(SUMMARIZE('A'[Date]))) The second one will includes the first one as its expression 'Number of Days (MTD)' := CALCULATE(TOTALMTD([Number of Days],'A'[Date])) The second measure when I browse the cube and pull out the measure. It runs incredibly slow. Any idea how I can optimize these measurements and make it run faster? Sample Data Volume:= SUMX(A, DIVIDE([Volume],2)) Volume (MTD):= TOTALMTD(

Average of Grouped Sum

▼魔方 西西 提交于 2019-12-07 16:23:25
问题 I am looking to create a measure that takes the average of several sums, grouped by an ID. An example would be if you had a database of customers that each purchased a variety of things, and you wanted to find the average amount that customers spent total sum all of their purchases grouped by customer, and then average out the result. I have considered a group by table, but if I do this then filters will not apply correctly to the results (unless there is a way to create a relationship

How to SUM a Column based on another column in DAX Powerpivot

我怕爱的太早我们不能终老 提交于 2019-12-07 12:02:25
Here is the example, +------+----+ | CARS | 3 | | CARS | 4 | | CARS | 6 | | CARS | 76 | | CARS | 4 | | CARS | 3 | | SUV | 32 | | SUV | 3 | | SUV | 3 | | SUV | 2 | | SUV | 3 | | SUV | 5 | +------+----+ I want to add a new calculated column with data like this +------+----+------+ | CARS | 3 | 96 | | CARS | 4 | 96 | | CARS | 6 | 96 | | CARS | 76 | 96 | | CARS | 4 | 96 | | CARS | 3 | 96 | | SUV | 32 | 48 | | SUV | 3 | 48 | | SUV | 3 | 48 | | SUV | 2 | 48 | | SUV | 3 | 48 | | SUV | 5 | 48 | +------+----+------+ Where it would sum up the number column for the type of vehicle. What would be the DAX

Custom x-axis values in Power BI

五迷三道 提交于 2019-12-07 11:41:29
I want to plot a graph over a year+weeknumber on the x axis. Each data-point contains this specific value; for example week 7 of 2016 is expressed as 201607 etc. and called YearWeek I created a date table in which I calculate all possible YearWeek value in a certain date-range. Then I created a YearWeek table extracting all distinct YearWeeks. This I connected to the Fact-Table. What I want to chart is exactly according to this matrix: Note that I explicitly selected to show items with no data to obtain the full time line. It continues down to 201852 but you get the picture. When I attempt to

How to format new measure (not column) in power BI as percentage?

妖精的绣舞 提交于 2019-12-07 05:08:07
问题 When I create a new measure with formula, i.e. sum(col1)/max(col2), it automatically converts the result into #.#% format. Strangely, it doesn't happen all the time; sometimes it just gives result #.## format. Any idea of how to format a new measure (not column) to be treated as percentage? 回答1: In Power BI there is a option in the taskbar when you enter your measure. In Power Pivot for Excel you can select the format directly in the measure editor (Or editor for calculated fields. The name

Multiple Linear Regression in Power BI

南笙酒味 提交于 2019-12-07 04:13:18
问题 Suppose I have a set of returns and I want to compute its beta values versus different market indices. Let's use the following set of data in a table named Returns for the sake of having a concrete example: Date Equity Duration Credit Manager ----------------------------------------------- 01/31/2017 2.907% 0.226% 1.240% 1.78% 02/28/2017 2.513% 0.493% 1.120% 3.88% 03/31/2017 1.346% -0.046% -0.250% 0.13% 04/30/2017 1.612% 0.695% 0.620% 1.04% 05/31/2017 2.209% 0.653% 0.480% 1.40% 06/30/2017 0

Measure in DAX to calculate YTD for chosen month only for Power BI

女生的网名这么多〃 提交于 2019-12-07 02:13:31
问题 How to construct DAX measure to calculate sum of YTD value for specific month? Here we have FactTable grouped by months. FactTable is filled with both Actual data and Forecast data. The only way to know when Actual end is information in table [Cut of date] in column [End of YTD]. In table [Cut of date] in column [End of YTD] – it is a single value table – we have the interesting chosen month, for which we want to see the calculation of YTD. In our case it is March. FactTable is updated

Min value with GROUP BY in Power BI Desktop

纵饮孤独 提交于 2019-12-06 15:02:57
问题 id datetime new_column datetime_rankx 1 12.01.2015 18:10:10 12.01.2015 18:10:10 1 2 03.12.2014 14:44:57 03.12.2014 14:44:57 1 2 21.11.2015 11:11:11 03.12.2014 14:44:57 2 3 01.01.2011 12:12:12 01.01.2011 12:12:12 1 3 02.02.2012 13:13:13 01.01.2011 12:12:12 2 3 03.03.2013 14:14:14 01.01.2011 12:12:12 3 I want to make new column, which will have minimum datetime value for each row in group by id. How could I do it in Power BI desktop using DAX query? 回答1: Use this expression: NewColumn =