Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Hi,
I have table and the table contains the following columns are item and country code.
Query1
The same item has two different country code are ADMK and DMK. If same item has two different country code then DMK is first concern and ADMK is second concern. I want unique code against each item within the table.
Data and Result:
item | country code | Result |
123 | ADMK | DMK |
123 | DMK | DMK |
1234 | ADMK | ADMK |
456 | DMK | DMK |
81 | DMK | DMK |
456 | ADMK | DMK |
890 | DMK | DMK |
890 | DMK | DMK |
564 | ADMK | DMK |
564 | DMK | DMK |
Query 2:
I have different situation.
I have a two tables are data and report in data table the following columns are item(item duplicated) and country code and report table item only(unique).
If same item has two different country code then DMK is first concern and ADMK is second concern.
I want unique item against the item in report table and if item does not exist then NA.
I am looking for New calculated column options without duplicaation columns.
Solved! Go to Solution.
You can easily replicate the logic of Excel formula in calcualted column,
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
Hi @Saxon10 ,
Please try the following calculated columns:
Column =
VAR DMK =
CALCULATE (
COUNTROWS ( DATA ),
FILTER (
DATA,
DATA[item] = EARLIER ( DATA[item] )
&& DATA[country code] = "DMK"
)
)
RETURN
IF ( DMK > 0, "DMK", [country code] )
Result =
VAR code =
CALCULATE (
MAX ( DATA[Column] ),
KEEPFILTERS ( DATA[item] = EARLIER ( REPORT[Item] ) )
)
RETURN
COALESCE ( code, "NA" )
If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
How can I replicated the same thing in power bi.
in Excel I am applying the following formula =IFERROR(IF(COUNTIFS(A$3:A$12,D3,B$3:B$12,"DMK"),"DMK",INDEX($B:$B,MATCH($D3,$A:$A,0))),"NA") (inbetween two tables)
Hi @Saxon10 ,
Please try the following calculated columns:
Column =
VAR DMK =
CALCULATE (
COUNTROWS ( DATA ),
FILTER (
DATA,
DATA[item] = EARLIER ( DATA[item] )
&& DATA[country code] = "DMK"
)
)
RETURN
IF ( DMK > 0, "DMK", [country code] )
Result =
VAR code =
CALCULATE (
MAX ( DATA[Column] ),
KEEPFILTERS ( DATA[item] = EARLIER ( REPORT[Item] ) )
)
RETURN
COALESCE ( code, "NA" )
If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
in Excel I am applying the following formula =IFERROR(IF(COUNTIFS(A$3:A$12,D3,B$3:B$12,"DMK"),"DMK",INDEX($B:$B,MATCH($D3,$A:$A,0))),"NA") (inbetween two tables)
Winth in table:
=IF(COUNTIFS($A$3:$A$12,$A3,$B$3:$B$12,"DMK"),"DMK",$B3)
You can easily replicate the logic of Excel formula in calcualted column,
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
thanks for your reply and your solution working well but I can't see the both table item columns reference in your formula? How do I know it's giving the correct result against the id? Is that possibile to add the both item columns reference in your formula or alternative way to achive the result inculding both table item columns reference?
I want the same result within the table. How can I get it? I am try to copy the same formula in data table but it's not working. can you assit me.
User | Count |
---|---|
93 | |
83 | |
77 | |
75 | |
66 |
User | Count |
---|---|
115 | |
105 | |
93 | |
65 | |
60 |