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
DGodQc
Frequent Visitor

Unable to retrieve a value with conditions

Hi all,

 

I'm trying to retrieve the good price for a specific Item in our Database. We have a Price_break table with Effective_Date and Deactive_Date.  I'm trying to create a lookupvalue with a filter, but i'm stuck.

breaks1.png

For a Item(ARINVT), i need to select the correct price for the currentday.  I've created a column with today's date in order to that(Probably can do it automatically in a formula, but i don't know yet how).

I have created a measure, but the output is not what i'm looking for.

 

PrixCOnv = calculate(
SELECTEDVALUE ( ARINVT_BREAKS[PrixConverti] );
FILTER (
ARINVT_BREAKS;(AND(ARINVT_BREAKS[EFFECT_DATE]<ARINVT_BREAKS[Today];or(ARINVT_BREAKS[DEACTIVE_DATE]>ARINVT_BREAKS[Today];(ARINVT_BREAKS[DEACTIVE_DATE]=blank()))))))
 
I've tried a calculatedcolumn with a lookupvalue, and i have problems with the filters.
Prixconve = LOOKUPVALUE( ARINVT_BREAKS[PrixConverti];ARINVT_BREAKS[ARINVT_ID];ARINVT[ID] )
FILTER (
ARINVT_BREAKS;(AND(ARINVT_BREAKS[EFFECT_DATE]<ARINVT_BREAKS[Today];or(ARINVT_BREAKS[DEACTIVE_DATE]>ARINVT_BREAKS[Today];(ARINVT_BREAKS[DEACTIVE_DATE]=blank()))))))
 
Thanks in advance for your advice!
Dany
 

 

1 ACCEPTED SOLUTION
v-xicai
Community Support
Community Support

Hi @DGodQc ,

 

From your description, you want to create a measure or column to get ARINVT_BREAKS[PrixConverti] while complying with specific conditions( one condition is

ARINVT_BREAKS[ARINVT_ID]=ARINVT[ID] , the other is to filter date),it is right? If yes, you can create a column using DAX below, readjust the formula to make it effective.

 

PrixCOnv = CALCULATE(SELECTEDVALUE ( ARINVT_BREAKS[PrixConverti] ),

           FILTER (ARINVT_BREAKS,             AND(ARINVT_BREAKS[EFFECT_DATE]<ARINVT_BREAKS[Today],or(ARINVT_BREAKS[DEACTIVE_DATE]>ARINVT_BREAKS[Today],ARINVT_BREAKS[DEACTIVE_DATE]=blank()))

&&ARINVT_BREAKS[ARINVT_ID]=ARINVT[ID] ))

 

Or you can share your sample data or screenshots for further analysis, upload sample pbix to OneDrive and post the link here. Do mask sensitive data before uploading.

 

Best Regards,

Amy

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-xicai
Community Support
Community Support

Hi  @DGodQc ,

 

Does that make sense? If so, kindly mark my answer as a solution to help others having the similar issue and close the case.

 

Best regards

Amy Cai

v-xicai
Community Support
Community Support

Hi @DGodQc ,

 

From your description, you want to create a measure or column to get ARINVT_BREAKS[PrixConverti] while complying with specific conditions( one condition is

ARINVT_BREAKS[ARINVT_ID]=ARINVT[ID] , the other is to filter date),it is right? If yes, you can create a column using DAX below, readjust the formula to make it effective.

 

PrixCOnv = CALCULATE(SELECTEDVALUE ( ARINVT_BREAKS[PrixConverti] ),

           FILTER (ARINVT_BREAKS,             AND(ARINVT_BREAKS[EFFECT_DATE]<ARINVT_BREAKS[Today],or(ARINVT_BREAKS[DEACTIVE_DATE]>ARINVT_BREAKS[Today],ARINVT_BREAKS[DEACTIVE_DATE]=blank()))

&&ARINVT_BREAKS[ARINVT_ID]=ARINVT[ID] ))

 

Or you can share your sample data or screenshots for further analysis, upload sample pbix to OneDrive and post the link here. Do mask sensitive data before uploading.

 

Best Regards,

Amy

 

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.

Top Solution Authors