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

Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more

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
PBIApril_Carousel

Power BI Monthly Update - April 2025

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

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

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

Top Solution Authors