Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hello, I have two tables of data and i'm trying to pull them both into a single table and also filter the results based on IF.
Here is sample data and what i'm trying to accomplish.
I have a relationship between tbl1 and tbl2 on SKU. What i want to do is say IF(TBL1[skutype]=TEST-A, "Test-A", "test-B") what it's doing is duplicating the rows and showing me both TEST-A and TEST-B but i want it to only show me Test-A in the results. Basically if TEST-A and TEST-B both exist for SKU A to show Test-A only.
Input TBL1 | Input TBL2 | ||||
SKU | SKU TYPE | SKU | QTY | DATE | |
A | TEST-A | A | 10 | 1/1/2020 | |
A | TEST-A | A | 10 | 1/1/2020 | |
A | TEST-B | A | 10 | 2/1/2020 | |
B | TEST-A | B | 10 | 1/4/2020 | |
C | TEST-B | C | 10 | 1/5/2020 | |
Desired output visual table | IF SKU IS SAME BUT TYPE IS DIFFERENT OVERRIDE AND SHOW TEST-A AND SUM QTY | ||
SKU | QTY | Date | SKU TYPE |
A | 20 | 1/1/2020 | TEST-A |
A | 10 | 2/1/2020 | TEST-A |
B | 10 | 1/4/2020 | TEST-A |
C | 10 | 1/5/2020 | TEST-B |
Solved! Go to Solution.
Hi @jmdesigns115
Please refer to attached sample file with the solution
SKU TYPE =
VAR CurrentSKUTypes =
CALCULATETABLE (
VALUES ( TBL1[SKU TYPE] ),
REMOVEFILTERS ( ),
VALUES ( TBL1[SKU] )
)
RETURN
IF (
NOT ISEMPTY ( TBL1 ) && HASONEVALUE ( TBL1[SKU] ),
IF (
"TEST-A" IN CurrentSKUTypes,
"TEST-A",
"TEST-B"
)
)
Hi,
to be honest i do not really understand your problem. You have a relationship betweeen both table with SKU. But it seems to be a m:n relationship. Because SKU "A" has "TEST-A" and "TEST-B", also duplicated values for SKU "A" and "Test-A" in table 1. Also your desired result is for my personal not clear.
Proud to be a Super User!
Hi @jmdesigns115
Please refer to attached sample file with the solution
SKU TYPE =
VAR CurrentSKUTypes =
CALCULATETABLE (
VALUES ( TBL1[SKU TYPE] ),
REMOVEFILTERS ( ),
VALUES ( TBL1[SKU] )
)
RETURN
IF (
NOT ISEMPTY ( TBL1 ) && HASONEVALUE ( TBL1[SKU] ),
IF (
"TEST-A" IN CurrentSKUTypes,
"TEST-A",
"TEST-B"
)
)
One side questions: Can only superuser upload directly files in this forum?
Proud to be a Super User!
This feels like it's on the right track but my SKU Type comes up empty. Having troule figuring out why it's returning nothing.
@jmdesigns115
Would you please update the same sample file with data that better simulates the actual case?
Thank you so much! Your solution worked. I accidentally chose new column instead of new measure when i used your solution. After making it a measure it worked.
User | Count |
---|---|
25 | |
12 | |
8 | |
6 | |
6 |
User | Count |
---|---|
26 | |
12 | |
11 | |
8 | |
7 |