Informatica report query - informatica

Please find the below requirement,i tried with route and a sort and aggregator but amnt getting the actual output
Source records
ID type amount desc
1 Credit 300 xyz
2 Debit 100 abc
1 Credit 400 xyz
1 Debit 500 xyz
1 Debit 200 xyz
2 Credit 200 abc
Result
1 Credit 300 xyz
1 Credit 400 xyz
1 Debit 700 ( total of 1 credit & des is null)
1 Debit 500 abc
1 Debit 200 abc
1 Credit 700
2 Credit 200 abc
2 Debit 200
2 Debit 100 abc
2 Credit 100

You could create a mapping with 2 branches:
The first branch simply passes the records without any change to data
The second branch aggregates amounts grouping by ID and Type
You can then put a Union to get all records together, then a Sorter on the same keys, ID and Type, to get data in the right order for the Target.
The mapping would look like this:
Source -> Expression -> Union -> Sorter -> Target
+-> Aggregator --^

Related

Flag everytime when ID change date DAX

I have table where with orders, articles belonging to orders and their shipping dates. What I want to do is, flag every time when shipping date changed or (when all dates for OrderID are the same) flag only once.
I tried to use calculated columns wrote in DAX, like nextdate, prevdate, nextorder, prevorder and reffer to them, but it doesn't work
I would appreciate every tip how to solve my prblem. Thanks!
OrderID
Article ID
Shipping date
Flag
123
1
01.01.2012
1
123
2
01.01.2012
0
123
1
02.01.2012
1
1234
12
15.03.2012
1
678
12
25.05.2014
1
678
345
25.05.2014
0
678
567
25.05.2014
0

How do I create a pivot table with weighted averages from a table in PowerBI?

I have data in the following format:
Building
Tenant
Type
Floor
Sq Ft
Rent
Term Length
1 Example Way
Jeff
Renewal
5
100
100
6
47 Fake Street
Tom
New
3
500
200
12
I need to create a visualisation in PowerBI that displays a pivot table of attribute by tenant, with a weighted averages (by square foot) column, like this:
Jeff
Tom
Weighted Average (by Sq Ft)
Building
1 Example Way
47 Fake Street
-
Type
Renewal
New
-
Floor
5
3
-
Sq Ft
100
500
433.3333333
Rent
100
200
183.3333333
Term Length (months)
6
12
11
I have unpivoted the original data, like this:
Tenant
Attribute
Value
Jeff
Building
1 Example Way
Jeff
Type
Renewal
Jeff
Floor
5
Jeff
Sq Ft
100
Jeff
Rent
100
Jeff
Term Length (months)
6
Tom
Building
47 Fake Street
Tom
Type
New
Tom
Floor
3
Tom
Sq Ft
500
Tom
Rent
200
Tom
Term Length (months)
12
I can almost create what I need from the unpivoted data using a matrix (as below), but I can't calculate the weighted averages column from that matrix.
Jeff
Tom
Building
1 Example Way
47 Fake Street
Type
Renewal
New
Floor
5
3
Sq Ft
100
500
Rent
100
200
Term Length (months)
6
12
I can also create a table with my attributes as headers (instead of in a column). This displays the right values and lets me calculate weighted averages (as below).
Building
Type
Floor
Sq Ft
Rent
Term Length (months)
Jeff
1 Example Way
Renewal
5
100
100
6
Tom
47 Fake Street
New
3
500
200
12
Weighted Average (by Sq Ft)
-
-
-
433.3333333
183.3333333
11
However, it's important that these values are displayed vertically instead of horizontally. This is pretty straightforward in Excel, but I can't figure out how to do it in PowerBI. I hope this is clear. Can anyone help?
Thanks!

Aggregate (Mean) of a resulting visual in Power BI

I am having a problem since I want an aggregated version of a filtered resulting visual.
Process:
Using a Text Filter:
a. Input Merchant ID and Year-Month.
Resulting Visual 1 will look like this if you input Merchant ID (1234) and Year-Month (2020-01):
Merchant ID CardNum Year-Month Amount
1234 1abc1 2020-01 1.00
1234 2def2 2020-01 100.00
1234 3ghi3 2020-01 65.00
Visual 2 then displays the Merchant History for each CardNumber listed in Visual 1.
Resulting Visual 2 will look like this:
Card Number Merchant ID Date Amount
1abc1 abc 2020-01 1.00
1abc1 def 2020-01 2.00
1abc1 xyz 2020-01 3.00
2def2 abc 2020-01 100.00
2def2 xyz 2020-01 200.00
3ghi3 abc 2020-01 300.00
Now I want something that will give me this output ordered from highest to lowest:
Merchant ID xRatio
abc 1
xyz 2/3
def 1/3
xRatio is the mean of Merchant ID occurrences aggregated over the card numbers
Detailed Explanation:
Merchant ID abc occurred for all 3 card numbers thus ((1+1+1)/3) is the result
Merchant ID xyz occurred for 2 card numbers thus ((1+1)/3) is the result
Merchant ID def occurred for 1 card number only thus (1/3) is the result
where "n" is the count of unique card numbers as seen in Visual 1
Create this following 3 measure and 1 custom column in given order in your table-
1.
distinct_card_number =
CALCULATE(
DISTINCTCOUNT(your_table_name[Card Number]),
ALL(your_table_name)
)
2. Create a custom column as below
card-merchant = your_table_name[Card Number] & "-" & your_table_name[Merchant ID]
3.
distinct_merchant_count = DISTINCTCOUNT(your_table_name[card-merchant])
4. now create the final measure as below-
xRatio =
IF(
[distinct_card_number] = [distinct_merchant_count],
"1",
[distinct_merchant_count] &"/"& [distinct_card_number]
)
Now add merchant_id and xRatio to your table visual. The output will be like below-

DAX Grouping and Ranking in Calculated Columns

My raw data stops at sales - looking for some DAX help adding the last two as calculated columns.
customer_id order_id order_date sales total_sales_by_customer total_sales_customer_rank
------------- ---------- ------------ ------- ------------------------- ---------------------------
BM 1 9/2/2014 476 550 1
BM 2 10/27/2016 25 550 1
BM 3 9/30/2014 49 550 1
RA 4 12/18/2017 47 525 3
RA 5 9/7/2017 478 525 3
RS 6 7/5/2015 5 5 other
JH 7 5/12/2017 6 6 other
AG 8 9/7/2015 7 7 other
SP 9 5/19/2017 26 546 2
SP 10 8/16/2015 520 546 2
Lets start with total sales by customer:
total_sales_by_customer =
var custID = orders[customer_id]
return CALCULATE(SUM(orders[sales], FILTER(orders, custID = orders[customer_id]))
first we get the custID, filter the orders table on this ID and sum it together per customer.
Next the ranking:
total_sales_customer_rank =
var rankMe = RANKX(orders, orders[total_sales_by_customer],,,Dense)
return if (rankMe > 3, "other", CONVERT(rankMe, STRING))
We get the rank per cust sales (gotten from first column), if it is bigger than 3, replace by "other"
On your first question: DAX is not like a programming language. Each row is assessed individual. Lets go with your first row: your custID will be "BM".
Next we calculate the sum of all the sales. We filter the whole table on the custID and sum this together. So in the filter we have actualty only 3 rows!
This is repeated for each row, seems slow but I only told this so you can understand the result you are getting back. In reality there is clever logic to return data fast.
What you want to do "Orders[Customer ID]=Orders[Customer ID]" is not possible because your Orders[Customer ID] is within the filter and will run with the rows..
var custid = VALUES(Orders[Customer ID]) Values is returning a single column table, you can not use this in a filter because you are then comparing a cell value with a table.

sas - group by two diff columns

I've the below dataset as input
ID category cust.nr cust.name income
1 a 100 Crosbie 5000
2 a 200 Heier 5500
2 a 300 Pick 5500
3 a 400 Sandridge 5100
4 b 500 Groesbeck 10000
4 b 600 Hayton 11000
4 b 700 Razor 12000
5 c 800 Lamere 90000
I need a report (f.ex using proc tabulate) as follows
In the data, cust.nr are unique but all the customers belonging to one family are given same ID, and customers are categorized based on their income.
<10000 as a
10000 to 15000 as b
'>'15000 as c
I need a report with
count of unique IDs(families), grouped by categories, and also rest of the columns need to be shown in the report.
so, it should look like
count_ID category cust.nr cust.name income
-------- ------ 100 Crosbie 5000
-------- ------ 200 Heier 5500
3 a 300 Pick 5500
-------- ------ 400 Sandridge 5100
-------- ------ 500 Groesbeck 10000
1 b 600 Hayton 11000
-------- -------- 700 Razor 12000
1 c 800 Lamere 90000
Any suggestions please..
You can do this easily with proc sql:
proc sql noprint;
create table results as
select category,
count(distinct id) as count_id
from mytable
group by 1
;
quit;