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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
PatrickNahayo
Frequent Visitor

Power DAX recommend at least one product that has the same price or higher.

I have the following table information. depicting the concept that i am dealing with. However, i have not been able to achieve any DAX calculations that can show the scenarios i depict below.

article idarticle namepriceavailable
1a10x
2b15 
3c12x
4d8x
5e10x
6f20x
7g18 
8h5 

i want the users to achieve the following scenarios
1. If the product is available, show it as it is.

2. If the product is not available do the following:

  2.1 recommend a product that is available with the same price

  2.2 recommend a product that is avaible with a higher price

 

This can be another column in the table or just shown on the fly if the user select a product.

 

Thank you very much for your help
@PowerBI 

8 REPLIES 8
PatrickNahayo
Frequent Visitor

@ryan_mayu @Ashish_Mathur thanks very much for the assistance, however, i want that there is a recommendation of more than one product. and I have tried with the CONCATENEX but to no results.

I want to achieve the following results

article idarticle namecategorycountrypriceavailablerecommended
1aaa1a10 b,c
2baa1a15x 
3caa1a12x 
4daa1a8x 
5ebb2a10 f,i
6fbb2a20x 
7gbb2a18 i
8hbb2a5x 
9ibb2a20x 

Hi,

This calculated column formula works

Articles = VAR _cat = Data[category]
            var _ctry = Data[country]
            var _price = Data[price]
            var _id = Data[article id]
VAR vTable =
    CALCULATETABLE (
        VALUES (Data[article name]),
        Data[category] = _cat,
        Data[country] = _ctry,
        Data[price]> _price,
        Data[available]="X",
        Data[article id]>_id,
        ALL (Data)
    )
VAR vResult =
    if(Data[available]="X",BLANK(),CONCATENATEX ( vTable, Data[article name], ", " ))
RETURN
    vResult

Hope this helps.

Ashish_Mathur_0-1701328786624.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

@Ashish_Mathur thanks very much for the help on this. However, i'm getting an out of memory error. Any idea on how to solve this?

PatrickNahayo_0-1702555447488.png

 

Sorry, i cannot help with that.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
PatrickNahayo
Frequent Visitor

@ryan_mayu thanks very much for this great example, and i'm sure it will be of great help in the future.
It has helped learn about new functions as well how to use variables in my DAX.
However, on detailed i missed is that the product can only be recommended, if the category is the same and is available in the same country.

article idarticle namecategorycountrypriceavailablerecommended
1aaa1a10 b
2baa1a15x 
3caa2a12x 
4daa2a8x 
5ebb3a10 f
6fbb3a20x 
7gbb4a18 i
8hbb4a5x 
9ibb4a20x 

I have tried multiple IFs but to no success. The outcomes should look like this in the table above.

@PatrickNahayo 

pls try this

Column = 
VAR _pro=minx(FILTER('Table','Table'[price]>=EARLIER('Table'[price])&&'Table'[available]="x"&&'Table'[country]=EARLIER('Table'[country])&&'Table'[category]=EARLIER('Table'[category])),'Table'[price])
return if('Table'[available]="x","",minx(FILTER('Table','Table'[available]="x"&&'Table'[price]=_pro&&'Table'[category]=EARLIER('Table'[category])&&'Table'[country]=EARLIER('Table'[country])),'Table'[article name]))

11.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi,

This calculated column formula works

Column = if(Data[available]=BLANK(),CALCULATE(MIN(Data[article name]),FILTER(Data,Data[category]=EARLIER(Data[category])&&Data[country]=EARLIER(Data[country])&&Data[available]="x"&&Data[price]>=EARLIER(Data[price]))),BLANK())

Hope this helps.

Ashish_Mathur_0-1700869343159.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
ryan_mayu
Super User
Super User

@PatrickNahayo 

is this what you want?

Column = 
VAR _pro=minx(FILTER('Table','Table'[price]>=EARLIER('Table'[price])&&'Table'[available]="x"),'Table'[price])
return if('Table'[available]="x",'Table'[article name],minx(FILTER('Table','Table'[available]="x"&&'Table'[price]=_pro),'Table'[article name]))

11.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors