Sumproduct & arrayformula - if-statement

I have two sheets, both have rows of data where one row represents a specific date in chronological order.
The sumproduct only needs to be made on the latest date (date in below example is in column A).
I set this up with:
=sum(ARRAYFORMULA((A3:A1000=max(A3:A1000))
So assuming that I need to sumproduct the two sheets on this specific row, I can't seem to figure out how to append the sumproduct formula into the arrayformula base.
The sumproduct is pretty basic. Assuming that row 12 is the latest date, I need Sheet 1 Cell B12 to multiply by Sheet 2 Cell B12, then sheet 1 cell C12 to multiply by Sheet 2 Cell C12 and so on.

sumproduct of whole last row of sheet1 with the same row from sheet2:
=ARRAYFORMULA(SUMPRODUCT(
INDIRECT("Sheet1!"&ADDRESS(MAX(IF(Sheet1!A:A="",,ROW(Sheet1!A:A))), 2)&
":"&MAX(IF(Sheet1!A:A="",,ROW(Sheet1!A:A)))),
INDIRECT("Sheet2!"&ADDRESS(MAX(IF(Sheet1!A:A="",,ROW(Sheet1!A:A))), 2)&
":"&MAX(IF(Sheet1!A:A="",,ROW(Sheet1!A:A))))))

Related

Conditional Format top 2 rows of a table visual power BI

I have a table visual with a date column and I have a requirement to highlight the top 2 rows. The data on the table visual is sorted desc by the date column.
I need help to conditional format the background color for the top 2 rows.
I tried searching for a way to do this but no luck.
You can calculate the rank of the rows and use conditional formatting to highlight the top 2 rows. But first, we need to define what "top 2 rows" means. You said it is sorted by date descending, so I will assume that "top 2 rows" means the rows with the 2 biggest dates. I will use a measure, which will respond to filters applied on the data. Then we will highlight the rows with rank 1 and 2 (assuming dates are unique in table's rows).
Make new measure like this:
Measure = RANKX(ALLSELECTED('Table'); CALCULATE(SELECTEDVALUE('Table'[Date])))
Where Table is your table name, and Date is the name of the date column. This will give you a number (1, 2, 3...) where 1 is the row with the biggest date, 2 is the second biggest date, and so on.
Then for every field shown in your table, add the following background color condition (right click each item in the list of fields and select Conditional formatting -> Background color):
Set Format by to be Rules, select your measure in Based on field and ad condition > 0 and <= 2 to set the desired background color. Repeat this for all fields shown.

How to do countifs in powerbi

I want to do countif in PowerBI (Example: count of total item with condition #1: having transaction of 2 or more, condition #2: year)
I have sample data comprised of PO (transaction) #, item #, date (year), item description, ship to location.
I can achieve the result through Excel - Pivot a matrix table of rows of items, columns of year and the value is count of PO/transactions. A separate table on the side is utilized to count the total item within Column (Years) that has transaction count > 2.
I can't figure out what DAX to use in PowerBI to achieve the same thing as I could with Excel:
Sample of transaction counts:
Usually COUNTIFS in Excel are implemented by use of CALCULATE(<expression>,<filter1>,<filter2>…) in Power BI, for example:
CALCULATE(SUM(Table1[Column1]), FILTER(Table1, Table1[Column1] < Table1[Column2]))
Read more details here.

Measure to count across multiple columns

I am new to Power BI - DAX functions.
I have three columns in a table with text in it and I have added a fourth column where I want the count of these three but when I use COUNTA, COUNTX or COUNTAX measure I am getting the count of the entire column.
COUNTA
COUNTAX
COUNTX
Column = COUNTX(Table1, Table1[First_Amendment])
+ COUNTX(Table1, Table1[Second_Amendment])
+ COUNTX(Table1, Table1[Third_Amendment])
Suppose column A, B, C contains three names, apple, mango, oranges respectively so in fourth column I should get count as 3.
Did you want to count no blank column based on row, right?
If so, you could try to use calculated column like below
Column = if((countaa[a])="",0,1)+if((countaa[b])="",0,1)+if((countaa[c])="",0,1)
You also could refer to this post for details.
Zoe

Adding a Total Column to a Matrix-Visual that only sums spcific columns

I have a table that has (simplified) the columns CustID, Action, Date
I then have a matrix visual that has Action as Columns, CustID AS Rows and Count(Action) as Values.
Now I need an extra column that sums only some of the Columns, not all like the Total. In Excel this is =SUMME(B11:K11), where K12 and K13 are the columns not to be summed.
Is this possible in PBI Matrix?
You can simply create a measure.
(new_measure_name) = 'table'[field to add] + 'table'[field to add]
After you create the measure you can add it to the matrix and double check you math that it adds up like you want.
Good luck!
my problem was, that I had a table column in the column section of the matrx visual. than, when I add a measure it is only available in drill, not as extra column. I solved it with pivoting that column and use the new columns in data section. than I can add measures to the data section and they get also new columns.
would be nice, if I could use the column section and add measures

Calculated column offset by 2

https://i.stack.imgur.com/BTjZv.jpg
I am trying to generate a calculated column B from column A. Notice that column B is basically the same rows as column A except it's offset by 2 rows. I'm trying to generate this with DAX but I don't even know where to begin. I would appreciate any help.
You can use in PowerBI the PowerQuery Editor to append a Column with 2 "null" values (as numeric type) like the example below:
append column in powerbi example
To get this result:
final result of "column B"
Think is a easy way to get what you want.