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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
Emerald70
Frequent Visitor

May to May data display on Power bi graphs

I have data from Jan 2022 to september 2024
I have 2 graphs
If I select on 2023 slicer
One graph is with sum(sales) from Jan 2023 to Dec 2023 to be displayed ( it is working)

However, my requirement is to display in another graph from May 2023 to May 2024  which is not working 
I have tried but it is showing from May 2023 to Dec 2023 

Could someone help me with this ?

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

Thanks for the reply from FlipFlop1 , please allow me to provide another insight: 
Hi  @Emerald70 ,

I created some data:

vyangliumsft_0-1726037155128.png

As far as I know, when the slicer makes a selection, the visual that is related to the slicer field also changes dynamically, you might consider creating a table with no join relationship and using measure to affect the two visuals separately.

Here are the steps you can follow:

1. Create calculated table.

Table 2 =
DISTINCT('Table'[Year])

vyangliumsft_1-1726037155130.png

2. Create measure.

Visual_May2023toMay 2024 =
var _select=SELECTEDVALUE('Table 2'[Year])
var _mindate=DATE(_select,5,1)
var _maxdate=EOMONTH(DATE(_select+1,5,1),-1)
return
IF(
MAX('Table'[Date])>=_mindate&&MAX('Table'[Date])<=_maxdate,1,0)
Visual_allyear =
var _select=SELECTEDVALUE('Table 2'[Year])
return
IF(
MAX('Table'[Year])=_select,1,0)

3. Place each of the two measures in the corresponding visual filter and set it to 1.

vyangliumsft_2-1726037424232.png4. Result:

vyangliumsft_3-1726037467291.png

 

 

Best Regards,

Liu Yang

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

Thanks for the reply from FlipFlop1 , please allow me to provide another insight: 
Hi  @Emerald70 ,

I created some data:

vyangliumsft_0-1726037155128.png

As far as I know, when the slicer makes a selection, the visual that is related to the slicer field also changes dynamically, you might consider creating a table with no join relationship and using measure to affect the two visuals separately.

Here are the steps you can follow:

1. Create calculated table.

Table 2 =
DISTINCT('Table'[Year])

vyangliumsft_1-1726037155130.png

2. Create measure.

Visual_May2023toMay 2024 =
var _select=SELECTEDVALUE('Table 2'[Year])
var _mindate=DATE(_select,5,1)
var _maxdate=EOMONTH(DATE(_select+1,5,1),-1)
return
IF(
MAX('Table'[Date])>=_mindate&&MAX('Table'[Date])<=_maxdate,1,0)
Visual_allyear =
var _select=SELECTEDVALUE('Table 2'[Year])
return
IF(
MAX('Table'[Year])=_select,1,0)

3. Place each of the two measures in the corresponding visual filter and set it to 1.

vyangliumsft_2-1726037424232.png4. Result:

vyangliumsft_3-1726037467291.png

 

 

Best Regards,

Liu Yang

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

Emerald70
Frequent Visitor

But I have to get the result based on selection right , I should select  bcz my DAX is like below

FilteredSales =
VAR SelectedYear = SELECTEDVALUE('Calendar'[Year])  // Capture the selected year from the slicer
VAR StartDate = DATE(SelectedYear, 5, 1)            // Define the start date as May 1st of the selected year
VAR EndDate = DATE(SelectedYear +1, 5,30)        // Define the end date as April 30th of the following year

RETURN
CALCULATE(
    SUM(MOM[Value]),
 FILTER(MOM,MOM[CustomDate] >= StartDate && MOM[CustomDate] <=  EndDate
    )
)

I would suggest just using current year and last year sales on the same graph:

FlipFlop1_0-1725980835969.png

DAX for last year as follows:

 

Sales LY = CALCULATE(SUMX(FactOnlineSales, (FactOnlineSales[SalesAmount])), SAMEPERIODLASTYEAR(DimDate[Datekey]))
 
This will work with the year selector.
FlipFlop1
Advocate I
Advocate I

It sounds like the 2023 slicer is slicing your 2nd graph. I you click on the slicer and select Format > Edit Interactions, you can prevent the slicer from acting on your graph (click the no-entry sign at the top right of the graph).  

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

Find out what's new and trending in the Fabric community.