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
likhithar
Helper III
Helper III

Selecting a random month for comparison

Hello alll,

I'm showing current month against some dimension and i want other month to be target for current month comparison(it's random)

for example if i'm showing July-2021 sales and i want Dec-2020 (it has to be dynamic..it can be May 2021)as the target.How to do this in Power BI Desktop??

likhithar_0-1626345526628.png

From the above scenario,2016-July is cur sales and target to be 2015 -June

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

Hi @likhithar 

Build an unrelated calendar table for target slicer and build a measure to show tagret value.

Unrelated calendar table

Target Slicer Table = ADDCOLUMNS(CALENDARAUTO(),"Year",YEAR([Date]),"Month",MONTH([Date]),"MonthName",FORMAT([Date],"MMMM"))

Target measure:

Target =
VAR _SELECTYEAR =
    SELECTEDVALUE ( 'Target Slicer Table'[Year] )
VAR _SELECTMONTH =
    SELECTEDVALUE ( 'Target Slicer Table'[MonthName] )
RETURN
    CALCULATE (
        SUM ( Sheet2[Value] ),
        FILTER (
            ALL ( Sheet2 ),
            Sheet2[Category] = MAX ( Sheet2[Category] )
                && Sheet2[Year] = _SELECTYEAR
                && Sheet2[MonthName] = _SELECTMONTH
        )
    )

Then we build a visual as below. 

1.png

Best Regards,

Rico Zhou

 

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-rzhou-msft
Community Support
Community Support

Hi @likhithar 

Build an unrelated calendar table for target slicer and build a measure to show tagret value.

Unrelated calendar table

Target Slicer Table = ADDCOLUMNS(CALENDARAUTO(),"Year",YEAR([Date]),"Month",MONTH([Date]),"MonthName",FORMAT([Date],"MMMM"))

Target measure:

Target =
VAR _SELECTYEAR =
    SELECTEDVALUE ( 'Target Slicer Table'[Year] )
VAR _SELECTMONTH =
    SELECTEDVALUE ( 'Target Slicer Table'[MonthName] )
RETURN
    CALCULATE (
        SUM ( Sheet2[Value] ),
        FILTER (
            ALL ( Sheet2 ),
            Sheet2[Category] = MAX ( Sheet2[Category] )
                && Sheet2[Year] = _SELECTYEAR
                && Sheet2[MonthName] = _SELECTMONTH
        )
    )

Then we build a visual as below. 

1.png

Best Regards,

Rico Zhou

 

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

 

NidhiBhusari
Helper IV
Helper IV

Hi @likhithar https://youtu.be/cyOquvfhzNM ...please refer this. I hope this will resolve your query.
Let me know whether it is working in your case or not.

NidhiBhusari
Helper IV
Helper IV

@likhithar Is it possible for you to share the sample dataset?

 

@NidhiBhusari  Attached an image in the question for reference.You can try with northwindmill dataset also

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.