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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Syndicate_Admin
Administrator
Administrator

Compare Selected Month to Month on Date

Hello, I have a graph in which the x-axis is the months of the year, I also have a column with a solution date, what I need is that if the solution date is less than or equal to the selected month, count the values related to that month

Luz_0-1715211344139.png

Only the fourth record would not correspond to the rule I need. Do you have any ideas on how to do this?

I appreciate your help.

3 REPLIES 3
v-nuoc-msft
Community Support
Community Support

Hi @Syndicate_Admin 

 

For your question, here is the method I provided:

 

Here's some dummy data

 

"Table"

vnuocmsft_0-1715222806433.png

 

"Date"

vnuocmsft_1-1715222823694.png

 

date = CALENDAR("1/1/2024", "12/31/2024")

 

Create a slicer visual object based on a date table for selecting a month.

 

Create a measure, query the selected month.

 

_month = SELECTEDVALUE('date'[Date].[MonthNo])

vnuocmsft_2-1715222920887.png

 

Create a measure. When the resolution date is less than or equal to the selected month, it is marked as 1, otherwise it is 0.

 

mark = 
IF(
    MONTH(SELECTEDVALUE('Table'[fecha_EstSol])) <= [_month],
    1, 
    0
)

 

vnuocmsft_3-1715223101588.png

 

You can put that measure into Filters for filtering and not show it in the visual object.

 

vnuocmsft_4-1715223221578.png

 

vnuocmsft_5-1715223236810.png

 

Here is the result.

vnuocmsft_6-1715223265426.png

Regards,

Nono Chen

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

 

 

 

Hi, I've tried your solution and have some issues.

At the time of selecting month 4, "valid" as of 09/05/2024 as true, it will have something to do with the fact that the date table is linked to a column of dates in my table where column Fecha_EstSol is, the problem is that the measurement I have related to the table is calculated like this:

Active1 =
were _min_date = minx(all('Date'),'Date'[Date])
were _Expression=if(ISFILTERED('Date'[Year]),maxx('Date',ENDOFMONTH(DATEADD('Date'[Date],-1,MONTH))),maxx('Date',DATEADD('Date'[Date],-1,YEAR)))
Return
CALCULATE(COUNTx(FILTER('demosgsi scanningvulnerabilitiesdetail','demosgsi scanningvulnerabilitiesdetail'[fecha_IniEsc]<=_Expression && 'demosgsi scanningvulnerabilitiesdetail'[fecha_IniEsc]>=_min_date && (ISBLANK('demosgsi scanningvulnerabilitiesdetail'[fecha_FinAten]) || 'demosgsi scanningvulnerabilitiesdetail'[fecha_FinAten]>_Expression)),('demosgsi scanningvulnerabilitiesdetail'[id])),CROSSFILTER('demosgsi scanningvulnerabilitiesdetail'[fecha_IniEsc],'Date'[Date],None))
Here's what it looks like by selecting a month
Luz_0-1715273531497.png

Here's what unselected data looks like

Luz_1-1715273550369.png

What I need is what you show in your table next to the Start value, but it looks modified with the selection.

Ritaf1983
Super User
Super User

Hi @Syndicate_Admin 
If the calculation is in the same year then you can use TOTALYTD dax function.
For example, if I want to count the orders, whose order date is less than or equal to the selected month it will look like this:

Ritaf1983_0-1715219152192.png

The pbix is attached

More information about the function here :

https://www.youtube.com/watch?v=BNZSoTYPYQs

 

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

 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.