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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.