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
JorisVoorn
Employee
Employee

COMPARE X

Hi guys,

 

I am looking for something like COMPAREX statement.

 

Imagine that I have two tables.

 

Table one contains sales data per day and identificator and products, Table to Contains identificator (relationship between these two tables is established byse on it) and treshold.

 

What I need to create is measure where is if statement:

 

if treshold >= sum of sales then SUMX

 

This is easy in terms of selection only one product but in case I select more products then the evalution will bring the incorrect results as the if statement will be like that:

 

if (treshold 1 + treshold 2) >= (sum of sales 1 + sum of sales 2) then SUMX

 

However I would need something like this:

 

if  (treshold 1 >= sum of sales 1) then SUMX1 + (treshold 2>=sum of sales 2) then SUMX2

 

But imagine that there is bung of products so not possible to hard code it like this.

 

Any ideas?

 

Thanks in advance

1 REPLY 1
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @JorisVoorn,

 

If you want to use DAX, you may use if function like below.

 

if(expression1>expression2,true result,false result, if(...),...,...)

If you want to use Power Query, you could have a reference of this blog.

 

If you need further help, please share some data sample and your desired output.

 

Best Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.