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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
elkjoperik
Helper II
Helper II

IF statement with SUM

Hi,

I have a challenge that I hope someone here can help me with.

 

Setup:

Chains are placed in local currency (LOC) and World wide (all chains into one) is set in USD (two different columns)

 

I want to create a meassure into a table, where I list all the chains, and also include world wide.

 

Since the figures are in different curriencies, a SUM-calculation on the LOC goes fine but it will state "Infinity" (since  the values is in a different coulmn) on the "World wide".

 

I want write a meassure that calculates  LOC AND USD as well so I present the results into ONE table.

 

-->IF SALESCHANNEL = chain, then SUM-calculation1, else; SUM-calulate world wide.  

 

I've tried with IF(CALCULATE,  IF(VALUES and such, but I don't get it right.   

 

PS, the SALESCHANNEL (chain / world wide ) is a text column, while to other columns is in whole number

 

Any tips? 

1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

Hi @elkjoperik,

 

According to your description, you want to transfer “LOC” currency to “worldwide” currency when “SALESCHANNEL” is chain, right?

You can follow the sample below:

 

I create two test tables.

Currency:
 Capture.PNG

Sales:

Capture2.PNG
 
Notice: type is the currency type.

 

Write the measure to calculate the current sales price.


Sales USD =
var channel=LASTNONBLANK(Sales[SALESCHANNEL],Sales[SALESCHANNEL])
var currentAmount=MAX(Sales[Amount])
var USDRate= LOOKUPVALUE('Currency'[World Wide],'Currency'[ID],MAX(Sales[Type]))
return
if(channel="chain", currentAmount / 100 * USDRate, currentAmount)

 

Add a table visual to display the result.
 Capture3.PNG

 

If above is not help, please provide more detail info about your requirement.

 

Regards,
Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

3 REPLIES 3
v-shex-msft
Community Support
Community Support

Hi @elkjoperik,

 

According to your description, you want to transfer “LOC” currency to “worldwide” currency when “SALESCHANNEL” is chain, right?

You can follow the sample below:

 

I create two test tables.

Currency:
 Capture.PNG

Sales:

Capture2.PNG
 
Notice: type is the currency type.

 

Write the measure to calculate the current sales price.


Sales USD =
var channel=LASTNONBLANK(Sales[SALESCHANNEL],Sales[SALESCHANNEL])
var currentAmount=MAX(Sales[Amount])
var USDRate= LOOKUPVALUE('Currency'[World Wide],'Currency'[ID],MAX(Sales[Type]))
return
if(channel="chain", currentAmount / 100 * USDRate, currentAmount)

 

Add a table visual to display the result.
 Capture3.PNG

 

If above is not help, please provide more detail info about your requirement.

 

Regards,
Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Awesome, thanks!

CahabaData
Memorable Member
Memorable Member

It is difficult to understand your data model from your post.  I would suggest you provide a very brief sample of the starting data table, and then a very brief sample of your goal/resulting data table.  If these are table visuals already with measures - a picture of those if possible.

 

 

www.CahabaData.com

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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