Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more

Reply
MikeFo
Frequent Visitor

Group by & Find/Replace?

Hi all

 

I have issues getting the right query for the scenario below. I appreciate it´s rather complicated to understand, but let me give it a try.

 

Table Name: Register

 

Credit NumberCurrencyCredit
1ABCEUR2,000
1ABCUSD25,000
1ABCHKD50,000
2HIJGBP35,000
3KLMHKD125,000

 

Conditions:

If 1 Credit Number has a Currency = EUR && a Currency = USD,

and if Credit for EUR is smaller than Credit for USD,

then I want to keep Credit for EUR and make Credit for USD as 0,

but if Credit for EUR is bigger than Credit for USD, I want to make both Credit as 0

if none of the above, keep Credit as is

 

Expected Outcome:

Credit Number CurrencyCredit
1ABCEUR2,000
1ABCUSD0
1ABCHKD50,000
2HIJGBP35,000
3KLMHKD125,000

 

Appreciate your thoughts!

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@MikeFo , Create a new column

new Credit =
Var _Eur = maxx(filter(Table, [Credit Number]=earlier( [Credit Number]) && [Currency]= "EUR"), [Credit])
Var _USD = maxx(filter(Table, [Credit Number]=earlier( [Credit Number]) && [Currency]= "USD"), [Credit])
Switch( True(),
_Eur > _USD && [Currency] in {"EUR", "USD"}, 0,
_Eur < _USD && [Currency] in {"USD"}, 0,
[Credit])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@MikeFo , Create a new column

new Credit =
Var _Eur = maxx(filter(Table, [Credit Number]=earlier( [Credit Number]) && [Currency]= "EUR"), [Credit])
Var _USD = maxx(filter(Table, [Credit Number]=earlier( [Credit Number]) && [Currency]= "USD"), [Credit])
Switch( True(),
_Eur > _USD && [Currency] in {"EUR", "USD"}, 0,
_Eur < _USD && [Currency] in {"USD"}, 0,
[Credit])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks, this helped. 

 

How would I apply this in the "Transform Data" view i.e. before the Close & Apply step?

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.