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
ekaponkratova
Frequent Visitor

Calculation when no country is selected

I have the below dataset and user country as a filter. The task is to calculate the revenue - calculated as sum paid in this month -  sum paid in the previous month. It should be calculated in USD. The solution of multiplying the exchange rate in the below table, then, creating a measure using PREVIOUSMONTH and then, doing subtraction doesn't work because of the high exchange rate fluctuation. 

12.png

The solution we came with was to calculate the revenue in the local currency. And then, if a user selects Switzerland from the filter, the revenue will be multiplied by the exchange rate for the corresponding country and corresponding date. 

2.png

Here are the formulas in practice:

Measures:
 
prior_month_sum_lc = CALCULATE(sum(fact_payment[sum_paid_to_date]),PREVIOUSMONTH(calendar_3[Date]))
 
revenue = sum(fact_payment[sum_paid_to_date])-[prior_month_sum_lc] 
 
revenue_usd = IF(SELECTEDVALUE(fact_payment[country])="Spain",
[revenue] * AVERAGEX(fact_payment,fact_payment[xr_es]),0 )
 

And it is working just fine when you select a particular country, however, I cannot a formula work when no country is selected. I've uploaded the sample at

https://drive.google.com/file/d/1ADLoDNSVBFo-G_SYj30xPH490yTDNXrL/view?usp=sharing.

 

My attempt to do the filter is in the measure final

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

Hi @ekaponkratova ,

 

To update your measure as below.

 

final_calc =
IF (
    ISFILTERED ( Sheet1[country] ) = FALSE (),
    CALCULATE (
        SUM ( Sheet1[cum sum paid] ),
        DATEADD ( 'calendar_3'[Date], -1, MONTH ),
        Sheet1[country] = "Spain"
    )
)

Capture.PNG

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

2 REPLIES 2
v-frfei-msft
Community Support
Community Support

Hi @ekaponkratova ,

 

To update your measure as below.

 

final_calc =
IF (
    ISFILTERED ( Sheet1[country] ) = FALSE (),
    CALCULATE (
        SUM ( Sheet1[cum sum paid] ),
        DATEADD ( 'calendar_3'[Date], -1, MONTH ),
        Sheet1[country] = "Spain"
    )
)

Capture.PNG

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
Anonymous
Not applicable

@ekaponkratova  - You'll want to do something like SUMX(YourTable[Raw Revenue]*ExchangeRates[Rate])

Because you need to calculate the value for each day and then sum them up.

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.