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
ncbshiva
Advocate V
Advocate V

Show data until selected month

Hi Team,

 

I have two measures "Compare From" and "Compare To" in my Fact Table. I need to show the data in the "Compare From" until my selected month. And my Compare To measure should show the data for all the months for the selected Year and it should ignore the month filter.

 

I have a month and year filter in my report. The relationship with my Date dimension is 1 to Many to my Fact Table.

 

For example : If my month filter is "May" and Year filter is "2019" then my "Compare From" measure should show the data from January 2019 till May 2019 selected month and year. Here my "Compare To" measure should show the data from Jan 2019 till Dec 2019.

 

Please help me with the DAX formula.

 

Regards

SHIVA 

 

 

1 ACCEPTED SOLUTION

Hi @ncbshiva ,

 

Have uploaded the sample .pbix file for your reference.

 

Regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
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

4 REPLIES 4
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @ncbshiva ,

 

Add a calendar table which is not linked to fact table. Add [YearNo] and [MonthName] from 'Date dimension' into slicers.

Date dimension =
ADDCOLUMNS (
    CALENDAR ( DATE ( 2018, 1, 1 ), DATE ( 2019, 12, 31 ) ),
    "YearNo", YEAR ( [Date] ),
    "MonthName", FORMAT ( [Date], "MMM" ),
    "MonthNo", MONTH ( [Date] )
)

Then, create measures as below.

Compare from =
IF (
    SELECTEDVALUE ( 'Fact'[Date].[Year] )
        = SELECTEDVALUE ( 'Date dimension'[YearNo] )
        && SELECTEDVALUE ( 'Fact'[Date].[MonthNo] )
            <= SELECTEDVALUE ( 'Date dimension'[MonthNo] ),
    SUM ( 'Fact'[Amount] ),
    BLANK ()
)

Compare to =
IF (
    SELECTEDVALUE ( 'Fact'[Date].[Year] )
        = SELECTEDVALUE ( 'Date dimension'[YearNo] ),
    SUM ( 'Fact'[Amount] ),
    BLANK ()
)

1.PNG

Best regards,

Yuliana Gu

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

Hi @v-yulgu-msft ,

 

Thanks for the mail , Can you please share me the pbix file ?

 

Regards

SHIVA

Hi @v-yulgu-msft ,

 

I tried in my pbix file it is not working , so i am asking can you please share me the pbix file which you have created these Compare To and Compare From measures.

 

Regards

SHIVA

Hi @ncbshiva ,

 

Have uploaded the sample .pbix file for your reference.

 

Regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
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 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.

Top Solution Authors