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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Anonymous
Not applicable

Dynamic Date Measure to filter the total number of licences which are only valid between dates

Hey everyone,

 

I couldn't solve a problem so I decided to ask for your help.

 

Currently, I am dealing with a data that has user names, and a certification type that is associated to each user. A certificate is only valid between specific dates (i.e. 05 March 2019-14 September 2023). Also, there are 5 types of certificates. 

 

I would like to draw a graph showing the cumulative sum of certificates available at the beginning of each month, with a certificate type breakdown. I tried to write a formula to calculate the cumulative sum, yet it is not dynamic adjusting the cumulative sum with respect to changing range of x-axis; which is the date in my case. 

 

Have you formulized such a problem before? If so, I would really appreciate your help.

 

Kind Regards,

Murat

1 REPLY 1
Anonymous
Not applicable

 

// Fact: Certification Info
// Dimensions with the type of connection:
// User 1:* Certification Info
// Certificate 1:* Certification Info
// Date (not connected to Certification Info)
// Certificate Type must be the attribute of Certificate
// and not be stored int the fact table.
//
// Assumptions:
// Date should be a Date table in the model.
// UI slicing only through dimensions.
// All columns in the fact table are hidden.

// This measure will grab the very first date
// visible in the currently selected period,
// (if you select jan 2020, it'll be
// 1st jan 2020) and calculate the number
// of certificates that were valid on this
// very day.
//
// If you connect Date to the fact table,
// this formula should be written differently.
// Here, the assumption is that no column in
// the fact table is exposed to the user. This
// is how it should be. If you decide to have
// a calendar connected to either of the fields,
// ValidFrom, ValidTo, the formula will not
// work correctly.
[# Cert At Period Start] =
var __firstDate = FIRSTDATE( Date[Date] )
var __certCount =
	CALCULATE(
		COUNTROWS( 'Certification Info' ),
		'Certification Info'[ValidFrom] <= __firstDate,
		'Certification Info'[ValidTo] >= __firstDate
	)
return
	__certCount

 

It's easy to get this measure by Cert Type and Periods (be it months or years or... whatever you define in Date). Just drag the attribute from the Certificate dimension onto somewhere....

 

Best

D

 

Helpful resources

Announcements
Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan NL Carousel

Fabric Community Update - January 2025

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