The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi All,
I would like to ask assistance in the scenario below:
currently have a table with the first three columns, and I want to add a column for the Transaction Group.
Rules:
> If Item group is MB, get the first item group with same transaction no.
> If item is not MB, get row item group.
Transaction No | Item | Item Group | Transaction Group |
1 | 1001 | AN | AN |
1 | 1002 | AN | AN |
1 | 1015 | MB | AN |
2 | 1004 | RR | RR |
2 | 1015 | MB | RR |
3 | 1001 | AN | AN |
3 | 1002 | AN | AN |
3 | 1015 | MB | AN |
3 | 1020 | RR | RR |
Thank you.
Solved! Go to Solution.
Hi Greg, this worked for my sample dataset. will check on the full dataset before accepting as solution. thank you.
Is this what you want?
You said you wanted the "row item group" if Item Group wasn't MB, but I wasn't sure what that meant. I pulled the item group from the same row.
Code here:
Column =
VAR varItemGroup = 'Table'[Item Group]
VAR varTransaction = 'Table'[Transaction No]
RETURN
IF(
varItemGroup = "MB",
MINX(
FILTER(
'Table',
'Table'[Transaction No] = varTransaction
),
'Table'[Transaction Group]
),
'Table'[Item Group]
)
Note: This is a calculated column formula and must be entered as a New Column to work.
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI ReportingHi. noticed that you used the transaction group column in the formula. What i meant was that, I am trying to have the trans group column be the output.
Thank you.
Ahh.. DIdn't understand TransactionGroup was the expected result. Try this @Anonymous
Column =
VAR varItemGroup = 'Table'[Item Group]
VAR varItem = 'Table'[Item]
VAR varTransaction = 'Table'[Transaction No]
RETURN
IF(
varItemGroup = "MB",
MINX(
FILTER(
'Table',
'Table'[Transaction No] = varTransaction
&& 'Table'[Item] < varItem
),
'Table'[Item Group]
),
'Table'[Item Group]
)
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI Reporting@Anonymous I think I got it correct, please check, I did not use Transaction Group in my formula.
@Anonymous Maybe:
Transaction Group =
IF(
"Item Group" = "MB",
VAR __First = MINX(FILTER('Table',[Transaction]=EARLIER([Transaction])),[Item])
RETURN
MAXX(FILTER('Table',[Transaction]=EARLIER([Transaction]) && [Item]=__First),[Item Group]),
[Item Group]
)
Hi Greg, this worked for my sample dataset. will check on the full dataset before accepting as solution. thank you.
User | Count |
---|---|
11 | |
8 | |
6 | |
6 | |
6 |
User | Count |
---|---|
24 | |
14 | |
13 | |
9 | |
8 |