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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Add culumn for a data range

Hi all,

 

this is my first Power BI lab test.

 

I have a table that contains the date of the next password change. I would like to extract all dates for password changes in the next 7, 15 and 30 days.

I don't know which is the best method, for example add a column with the number of days (7, 15, 30) or something else. I would like to create a pie chart indicating the number of passwords to change that fall within the three periods (1-7 - 8-15, 16-30). 

 

- All lines with expiration before today's date must be excluded
- All lines with expiration beyond 30 days must be excluded

 

2021_04_17_17_27_21_Compliance_BI_Editor_di_Power_Query.png

 

Pie.png

 

Thanks for those who want to give me some suggestions.

 

Nino

1 ACCEPTED SOLUTION
AlB
Community Champion
Community Champion

Hi @Anonymous 

See the attached file for a possible solution.

You need to create an ancillary table and a measure:

 

Password change = 
VAR currentPeriod_ = SELECTEDVALUE(PeriodT[Period])
VAR today_ = TODAY()
RETURN
SWITCH(currentPeriod_,
       7, COUNTROWS(FILTER(Table1, DATEDIFF(today_, Table1[Next Password],DAY) <= 7)),
       15, COUNTROWS(FILTER(Table1, DATEDIFF(today_, Table1[Next Password],DAY) > 7 && DATEDIFF(today_, Table1[Next Password],DAY) <= 15)),
       30, COUNTROWS(FILTER(Table1, DATEDIFF(today_, Table1[Next Password],DAY) > 15 && DATEDIFF(today_, Table1[Next Password],DAY) <= 30))
)

 

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

View solution in original post

3 REPLIES 3
AlB
Community Champion
Community Champion

@Anonymous 

I had forgotten to attach the file before. Have you seen it? Download and you'll see the steps there

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

AlB
Community Champion
Community Champion

Hi @Anonymous 

See the attached file for a possible solution.

You need to create an ancillary table and a measure:

 

Password change = 
VAR currentPeriod_ = SELECTEDVALUE(PeriodT[Period])
VAR today_ = TODAY()
RETURN
SWITCH(currentPeriod_,
       7, COUNTROWS(FILTER(Table1, DATEDIFF(today_, Table1[Next Password],DAY) <= 7)),
       15, COUNTROWS(FILTER(Table1, DATEDIFF(today_, Table1[Next Password],DAY) > 7 && DATEDIFF(today_, Table1[Next Password],DAY) <= 15)),
       30, COUNTROWS(FILTER(Table1, DATEDIFF(today_, Table1[Next Password],DAY) > 15 && DATEDIFF(today_, Table1[Next Password],DAY) <= 30))
)

 

 

SU18_powerbi_badge

Please accept the solution when done and consider giving a thumbs up if posts are helpful. 

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

 

Anonymous
Not applicable

Hi @AlB,

 

your solution works for may problem.

 

Below is the product graph

2021_04_17_17_27_21_Compliance_BI_Editor_di_Power_Query.png

 

 

Thank a lot

Nino

 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.