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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Reference a Price from the same Table

Hi,

 

I am trying to achive a measure in which Price of the select the month should be displayed, if the Price is not available in that month then it should show case the Next available price
 

I have Used a unlink calendar for the reference Month Year selection

This is the Requirement:

Materialplant CustomerDateSales PriceReference Price 1-03-2020
M0001P001CSM00101-01-20209069
M0001P001CSM00101-02-20208969
M0001P001CSM00101-03-20206969
M0001P001CSM00101-06-20209069
M0001P001CSM00101-07-20201869
M0001P001CSM00101-08-20208269
M0001P001CSM00101-09-20205669
M0002P001CSM00101-01-20209064
M0002P001CSM00101-02-20209964
M0002P001CSM00101-07-20206464
M0002P001CSM00101-08-20202264

 

 

The Measure that i am trying to build:

ReferencePeriod = SELECTEDVALUE( 'Calendar Table'[Start of Month] )

ReferencePrice = VAR ReferencePeriod = [ReferencePeriod]

VAR ReferenceTable =

    SUMMARIZE (

        CALCULATETABLE ( ‘Table’, ‘Table’[Date] >= ReferencePeriod, REMOVEFILTERS(Date)),

        ‘Table’[Plant],

        ‘Table’[Material],

        ‘Table’[Customer],

        "SalesPrice",

            VAR Price =

                CALCULATE (

                    MAX ( ‘Table’[Sales Price] ),

                    ‘Table’[Date] = ReferencePeriod,

                    REMOVEFILTERS ( DimDate )

                )

            VAR PriceMPlus1 =

                CALCULATE (

                    MAX ( ‘Table’[Sales Price] ),

                    ‘Table’[Date] = EDATE ( ReferencePeriod, 1 ),

                    REMOVEFILTERS ( DimDate )

                )

            VAR PriceMPlus2 =

                CALCULATE (

                    MAX ( ‘Table’[Sales Price] ),

                    ‘Table’[Date] = EDATE ( ReferencePeriod, 2 ),

                    REMOVEFILTERS ( DimDate )

                )

            VAR PriceMPlus3 =

                CALCULATE (

                    MAX ( ‘Table’[Sales Price] ),

                    ‘Table’[Date] = EDATE ( ReferencePeriod, 3 ),

                    REMOVEFILTERS ( DimDate )

                )

            RETURN

                SWITCH (

                    TRUE (),

                    NOT ( ISBLANK ( Price ) ), Price,

                    ISBLANK ( Price ), PriceMPlus1,

                    ISBLANK ( PriceMPlus1 ), PriceMPlus2,

                    ISBLANK ( PriceMPlus2 ), PriceMPlus3,

                    Price

                )

    )

RETURN

    SUMX ( ReferenceTable, [SalesPrice] )

 

1 ACCEPTED SOLUTION
v-yueyunzh-msft
Community Support
Community Support

Hi , @Anonymous 

According to your description, you want to achive a measure in which Price of the select the month should be displayed, if the Price is not available in that month then it should show case the Next available price.

Here are the steps you can refer to :
(1)This is my test data:

vyueyunzhmsft_0-1683171593637.png

I create a calendar table like this:

vyueyunzhmsft_1-1683171613051.png

(2)We can create a measure like this:

Measure = var _slicer = MIN('Calendar'[Date])
var _has_value =MAXX( FILTER( 'Table' , 'Table'[Date]=_slicer) , [Sales Price])
var _no_value_date = MINX(  FILTER('Table' , 'Table'[Date]>_slicer) , [Date])
var _no_value =MAXX( FILTER('Table' , 'Table'[Date] = _no_value_date) , [Sales Price])
return
IF(_has_value=BLANK(),_no_value,_has_value)

 

(3)Then we can put the measure on the visual and we can meet your need:

vyueyunzhmsft_2-1683171646753.png

 

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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

3 REPLIES 3
Anonymous
Not applicable

Hi,

 

Thanks for the Response it was very Helpful and Has solve the problem 90%, the Price should repeat for all the Months/date as Show cased in Img 2.
I have tried to use AllExcept funtion and All funtion to avoid the Date filter But no Luck.

 

Img 1

MohitTaco_0-1683179797989.png

Img 2 

MohitTaco_1-1683179870986.png

 

Hi , @Anonymous 

Thanks for your quick response !

According to your description, you want to show all in your table .

You can try to use this dax code:

Measure = var _slicer = MIN('Calendar'[Date])
var _material= MAX('Table'[Material])
var _has_value =MAXX( FILTER(ALLSELECTED('Table') , 'Table'[Date]=_slicer && 'Table'[Material]=_material) , [Sales Price])
var _no_value_date = MINX(  FILTER(ALLSELECTED('Table') , 'Table'[Date]>_slicer  && 'Table'[Material]=_material) , [Date])
var _no_value =MAXX( FILTER(ALLSELECTED('Table') , 'Table'[Date] = _no_value_date  && 'Table'[Material]=_material) , [Sales Price])
return
IF(_has_value=BLANK(),_no_value,_has_value)

 

vyueyunzhmsft_0-1683180660525.png

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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

 

v-yueyunzh-msft
Community Support
Community Support

Hi , @Anonymous 

According to your description, you want to achive a measure in which Price of the select the month should be displayed, if the Price is not available in that month then it should show case the Next available price.

Here are the steps you can refer to :
(1)This is my test data:

vyueyunzhmsft_0-1683171593637.png

I create a calendar table like this:

vyueyunzhmsft_1-1683171613051.png

(2)We can create a measure like this:

Measure = var _slicer = MIN('Calendar'[Date])
var _has_value =MAXX( FILTER( 'Table' , 'Table'[Date]=_slicer) , [Sales Price])
var _no_value_date = MINX(  FILTER('Table' , 'Table'[Date]>_slicer) , [Date])
var _no_value =MAXX( FILTER('Table' , 'Table'[Date] = _no_value_date) , [Sales Price])
return
IF(_has_value=BLANK(),_no_value,_has_value)

 

(3)Then we can put the measure on the visual and we can meet your need:

vyueyunzhmsft_2-1683171646753.png

 

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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

 

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.