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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
ThomasWeppler
Impactful Individual
Impactful Individual

Combining max and if

Hi Power BI community

I have a feeling that this question has a somewhat simple answer but I just cannot figure it out so I hope someone here can help me.
I want to write a function that look at the amount and divide it by a 100 
E. udgifter = divide(amount,100)
but if multiple rows with the same todoid and budgetpostid I only want to include the last of them with is the one with the highest id number and set the amout to the other ones to zero.
I think the solution is to combine max and if function so it only look at the highest id, but only have it apply if a row has both the same todoid and budgetpostid.

I have added a screenshot and I just want the row with id = 1159 ti have E. udgifter = 0, because another amount was posted later.

maxandif.png

 

I hope someone here can help me on my way.

1 ACCEPTED SOLUTION
ddpl
Solution Sage
Solution Sage

Hey I have solution in Power Query,

 

Step 1: Merge the column todoid and budgetpostid, named as g_b

 

Step 2: Group by the column g_b

 

bin3.png

 

 

 

 

 

 

 

 

 

 

 

 

Step 3: Expand the rest table

 

Step 4: Add Custom Column

amount_temp = if [id_temp] = [id] then [amount] else 0

 

Step 5: Add Custom Column

E. udgifter = [amount_temp]/100

 

remove unnecessary columns and that's it.

 

I hope It will work for you.

View solution in original post

2 REPLIES 2
ddpl
Solution Sage
Solution Sage

Hey I have solution in Power Query,

 

Step 1: Merge the column todoid and budgetpostid, named as g_b

 

Step 2: Group by the column g_b

 

bin3.png

 

 

 

 

 

 

 

 

 

 

 

 

Step 3: Expand the rest table

 

Step 4: Add Custom Column

amount_temp = if [id_temp] = [id] then [amount] else 0

 

Step 5: Add Custom Column

E. udgifter = [amount_temp]/100

 

remove unnecessary columns and that's it.

 

I hope It will work for you.

ThomasWeppler
Impactful Individual
Impactful Individual

Thanks a lot

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.