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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.