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
lcfaria
Helper II
Helper II

Calculation Group to convert currency - How ignore for measures that are not currency?

Hi all,

 

I created a simple calculation group to convert my currency from USD to EUR.

 

It is a simple query:

lcfaria_0-1653824776303.png

 

The problem is that I don't want to apply this calculation group to quantity, just to currency measures.

 

I tried to use REMOVEFILTERS, but it didn't work:

CALCULATE(
     SUM(factTable[Qty]),
     REMOVEFILTERS('CalculationGroup'[Convertion])
)
 

Is there any way to not consider this calculation group for some measures?

 

Thanks!

1 ACCEPTED SOLUTION

You need to consider the filter context.

 

When you apply the calculation group:

SUMX(
    factTable;
    SELECTEDMEASURE() * 0,9
)

 

which evaluates to 

SUMX(
    factTable;
    AVERAGEX(
        VALUES('Calendar'[Date]);
        [Sum Total]
    ) * 0,9
)

 

SUMX iterates over factTable, and for each row it calculates the average of that row. And the average of a single row is the same as the value of that row. So with this calculation group, both [Avg/Day] and [Sum Total] returns the same value.

I can't see any reason why you could not replace the current calculation group 

=SUMX(
    factTable;
    SELECTEDMEASURE() * 0,9
)

with 

=SELECTEDMEASURE() * 0,9

 

And with the latter you will get the correct values with both measures.

View solution in original post

4 REPLIES 4
sturlaws
Resident Rockstar
Resident Rockstar

Hi,

 

have you tried using SELECTEDMEASURENAME() combined with an if-statement?

=
IF (
    SELECTEDMEASURENAME () = "some measure",
    SELECTEDMEASURE (),
    SUMX ( facttable, SELECTEDMEASURE () * 0.9 )
)

 

Cheers,
Sturla

If this post helps, then please consider Accepting it as the solution. Kudos are nice too.

@sturlawsyour solution worked fine, but I ran into another problem.

 

I have a measure that calculates the average per day, but when I apply the calculation group, the result is not correct. Instead of bringing me the converted average value, this brings me the converted value of the measure [Sum Total].

 

Measures:

lcfaria_0-1653842269213.png

lcfaria_1-1653842278555.png

 

Whitout applying calculation group:

lcfaria_2-1653842343598.png

Applying calcution group:

lcfaria_3-1653842371425.png

 

Do you know how I can get around this?

 

I am attaching the sample file in this link: https://1drv.ms/u/s!At5JlMR_naI1gf4zcSKNi8b27E6Evg?e=eJcULs

You need to consider the filter context.

 

When you apply the calculation group:

SUMX(
    factTable;
    SELECTEDMEASURE() * 0,9
)

 

which evaluates to 

SUMX(
    factTable;
    AVERAGEX(
        VALUES('Calendar'[Date]);
        [Sum Total]
    ) * 0,9
)

 

SUMX iterates over factTable, and for each row it calculates the average of that row. And the average of a single row is the same as the value of that row. So with this calculation group, both [Avg/Day] and [Sum Total] returns the same value.

I can't see any reason why you could not replace the current calculation group 

=SUMX(
    factTable;
    SELECTEDMEASURE() * 0,9
)

with 

=SELECTEDMEASURE() * 0,9

 

And with the latter you will get the correct values with both measures.

Hey @sturlaws you are right, I made this change in the calculation group and it worked as expected.

 

Thank you very much for your attention and explanation on this topic. It helped me clarify things a little more. 👊

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.