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
Anonymous
Not applicable

filter by another columns text

Dear All,

 

I would like to ask for your help on the below topic. 

 

What I would like to do is to say to power bi to create a measure where on the below table (example) to keep the values of EUR for the country of Poland and for the rest keep local currency.

 

AmountReporting CurrencyCountry by Business
166LocalPoland
38EURPoland
1000LocalSweden
100EURSweden
50LocalGermany
50EURGermany

 

Any idea?

 

In case you need any further explanation please let me know.

 

Best regards,

1 ACCEPTED SOLUTION

I think this will work:

 

Country Profit = 
SUMX(
    FILTER(
        'Europe Profit',
        var CurrencyCode = 
            IF(
                MAX('Europe Profit'[Country by Business]) = "Poland",
                "EUR",
                "Local"
            )
        RETURN
        'Europe Profit'[Reporting Currency] = CurrencyCode
    ),
    'Europe Profit'[Conv. Rate]
)


Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

9 REPLIES 9
edhans
Super User
Super User

Not sure what you mean when you say measure, as that should create a scalar value. If you mean a calculated table, the following DAX will create that by creating a new Table, then pasting this code in.

Table 2 = 
FILTER(
	'Table',
	('Table'[Country by Business] = "Poland" && 'Table'[Reporting Currency] = "EUR")
	||
	('Table'[Country by Business] <> "Poland" && 'Table'[Reporting Currency] = "Local")
	)

 If your data is coming from an imported source,  Power Query is often a better alternative, but not sure what exactly you are doing, so pick the right tool for the job. To do this in Power Query, it is identical filter logic, just different syntax.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcszNL80rUdJRCkotyC8qycxLV3AuLSpKzUuuBAo6gySLKhWSKhWcSosz81KLi5VidaKVDM3MgLI++cmJOUA6ID8nMS8FLGFsAeS7hgahihoaGBggqQ8uT01JzYPJwDUgCZsiK3dPLcpNzKtESECUw4VjAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t]),
    #"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
    #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Amount", Int64.Type}, {"Reporting Currency", type text}, {"Country by Business", type text}}),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each (([Country by Business] = "Poland") and ([Reporting Currency] = "EUR") or ([Country by Business] <> "Poland") and ([Reporting Currency] = "Local")))
in
    #"Filtered Rows"

Paste that into a new Blank Query in Power Query via the Advanced Editor. Ignore the first 4 rows. All you really care about to exampine is the #"Filtered Rows" logic. The first few rows are just storing the binary blob of that table and formatting it properly.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
Anonymous
Not applicable

Hi @edhans ,

 

No I dont think I made myself clear on that. 

 

So what I want is to build a table where at the end of the day I will show only one currency the Local one. But in case I have the country of Poland I want it to show the EUR values in stead of the local.

 

So I want it to do is to say : if I have Poland find the give me the values where it shows EUR.

 

Let me know if it is clear,

 

Cheers,

 

Paris

 

I thought that is what I did:

2020-03-23_10-58-13.png

If that isn't right, then please mock something up in Excel explaining what you have, and how you want the expected output to look and post screenshots.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
Anonymous
Not applicable

@edhans  Yes this is what i wanted. Small difference is that I want it without the column of Reporting Currency. 

 

but I dont want to built a new table just to take that. I need a measure that will filter both columns and it will give the proper value.

Reporting Currency Amount = 
VAR Country = MAX('Table'[Country by Business])
VAR CurrencyCode = 
    IF(
        Country = "Poland",
        "EUR",
        "Local"
    )
RETURN
CALCULATE(
    MAX('Table'[Amount]),
    FILTER(
        'Table',
        'Table'[Reporting Currency] = CurrencyCode
    )
)


Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
Anonymous
Not applicable

hi @edhans 

 

Yes this can work but I have more than 1 lines to sum on the column of the values. in this formula it only returns the Max value of the country.

 

So the question is, how I should tell it to gather all the values  and sum them?

 

Example.

 Conv. Rate DateReporting CurrencyCountry by Business
                 1.662/1/2020 0:00EURPoland
              11.822/1/2020 0:00EURPoland
            387.832/1/2020 0:00EURPoland

I'm going to ask again. Show your data you have now, in a table format. Then show some screenshots or output of what you expect. This thread is now 7-8 deep and this is the first time you've asked for a SUM. Help me help you. Provide a clear and complete explanation of what you are looking for.

How to Get Your Question Answered Quickly
How to provide sample data in the Power BI Forum



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
Anonymous
Not applicable

Hi @edhans  I am sorry for all the misunderstood and once again thank you for all your support on this! 🙂

 

Look the below table is the info that I have: 

AccountsConv. RateReporting CurrencyCountry by Business
1. Gross Profit           7.15LocalPoland
1. Gross Profit         51.01LocalPoland
1. Gross Profit   1,672.99LocalPoland
1. Gross Profit         11.82EURPoland
1. Gross Profit      387.83EURPoland
1. Gross Profit         45.25EURPoland
1. Gross Profit216.14LocalSweden
1. Gross Profit5.86LocalSweden
1. Gross Profit220.46LocalSweden
1. Gross Profit1,761.57LocalSweden
1. Gross Profit20.29EURSweden
1. Gross Profit0.55EURSweden
1. Gross Profit20.70EURSweden
1. Gross Profit165.41EURSweden

 

And here is what I want to see.

 

Country by BusinessConv. Rate
Poland444.9 
Sweden2204.02

 

For Poland is the sum of EUR and for Sweden  (and rest of countries that I have) Local reporting currency.

 

Let me know if you need further info.

 

Cheers,

I think this will work:

 

Country Profit = 
SUMX(
    FILTER(
        'Europe Profit',
        var CurrencyCode = 
            IF(
                MAX('Europe Profit'[Country by Business]) = "Poland",
                "EUR",
                "Local"
            )
        RETURN
        'Europe Profit'[Reporting Currency] = CurrencyCode
    ),
    'Europe Profit'[Conv. Rate]
)


Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

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.