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
toovishant
Helper II
Helper II

Calculate the count of 100% or more in 30, 60 and 90 days

Hi Team,

 

I need to create a view, where the calculated column on % by bl_id needs to find how many times it is either equal to or greater than 100% for 30, 60, and 90 days.

 

Below is the sample test data set

https://docs.google.com/spreadsheets/d/1vbW6c764C44pUayLUgKYUACDq8X-1w11/edit?usp=sharing&ouid=10867...

 

Required view

toovishant_0-1703777853466.png

 

Thanks,

Vishant

 

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

Hi @toovishant 

 

I have a certain understanding of your question.

You need to filter the number of entries in the bl_id percentage column by time range (30 days, 60 days, 90 days).

Here is the solution:

Based on the example data you gave, I created a table to store a set date range, such as 30, 60, 90 days

vzhengdxumsft_4-1703829235868.png

Then created a measure that is used to calculate the number of bars that exceed 100% in 30, 60, 90 days, respectively:

--------------------------------------------------

%by bl_id() =

VAR selectrange = SELECTEDVALUE('Table'[Value])

// Used to extract the required date range from the newly created table

    VAR range_DAY = SWITCH(

        selectrange,

        "%by bl_id(30)", 30,

        "%by bl_id(60)", 60,

        "%by bl_id(90)", 90

    )

// Since selectrange extracts text values, the text is converted to numbers via switch

    VAR current_date = MIN('data'[Date])

// Extract the current value

    VAR end_date = MAXX(

        FILTER(

            ALL('data'),

            'data'[Date] <= current_date + range_DAY

        ),

        'data'[Date]

    )

// Gets the end value of the date

    RETURN

        CALCULATE(

            COUNTROWS('data'),

            'data'[Utilization %] >= 1 && 'data'[Date] >= current_date && 'data'[Date] < end_date

        )

//Obtain the number of entries with a percentage of more than 1 in this date range.

--------------------------------------------------

Once you've set it up, create a matrix with [bl_id] rows and [value] in columns, and [%by bl_id()] in values.

Also use [date] to create a slicer, which can be used to set the current_date, and the result is that you can choose a point in time, and the matrix will show the percentage of values that exceed 1 in the 30th, 60th, and 90th days after that point in time.

vzhengdxumsft_5-1703829235874.png

By using this method, you can easily set the date range (you can add dates to the 'Table' [value], for example, if you want to filter the number of entries within 120 days, you just need to add "%by bl_id(120)", and add "%by bl_id(120)" to the switch in measure, 120).

 

Best Regards,

Zhengdong Xu

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

7 REPLIES 7
v-zhengdxu-msft
Community Support
Community Support

Hi @toovishant 

 

I have a certain understanding of your question.

You need to filter the number of entries in the bl_id percentage column by time range (30 days, 60 days, 90 days).

Here is the solution:

Based on the example data you gave, I created a table to store a set date range, such as 30, 60, 90 days

vzhengdxumsft_4-1703829235868.png

Then created a measure that is used to calculate the number of bars that exceed 100% in 30, 60, 90 days, respectively:

--------------------------------------------------

%by bl_id() =

VAR selectrange = SELECTEDVALUE('Table'[Value])

// Used to extract the required date range from the newly created table

    VAR range_DAY = SWITCH(

        selectrange,

        "%by bl_id(30)", 30,

        "%by bl_id(60)", 60,

        "%by bl_id(90)", 90

    )

// Since selectrange extracts text values, the text is converted to numbers via switch

    VAR current_date = MIN('data'[Date])

// Extract the current value

    VAR end_date = MAXX(

        FILTER(

            ALL('data'),

            'data'[Date] <= current_date + range_DAY

        ),

        'data'[Date]

    )

// Gets the end value of the date

    RETURN

        CALCULATE(

            COUNTROWS('data'),

            'data'[Utilization %] >= 1 && 'data'[Date] >= current_date && 'data'[Date] < end_date

        )

//Obtain the number of entries with a percentage of more than 1 in this date range.

--------------------------------------------------

Once you've set it up, create a matrix with [bl_id] rows and [value] in columns, and [%by bl_id()] in values.

Also use [date] to create a slicer, which can be used to set the current_date, and the result is that you can choose a point in time, and the matrix will show the percentage of values that exceed 1 in the 30th, 60th, and 90th days after that point in time.

vzhengdxumsft_5-1703829235874.png

By using this method, you can easily set the date range (you can add dates to the 'Table' [value], for example, if you want to filter the number of entries within 120 days, you just need to add "%by bl_id(120)", and add "%by bl_id(120)" to the switch in measure, 120).

 

Best Regards,

Zhengdong Xu

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

olgad
Super User
Super User

Measure = Calculate(COUNTROWS('dataTable'), 'dataTable'[Utilization %]>=1)

You can see in my case i took the countries instead of classification and for China it counts 5 times and then on the right you can see that indead China has 5 times 100 or more percent. Hope it helps. 

olgad_0-1703780797374.png

 


DID I ANSWER YOUR QUESTION? PLEASE MARK MY POST AS A SOLUTION! APPRECIATE YOUR KUDO/LIKE!
PROUD TO BE A SUPER USER!
Best Stories, Interesting Cases: PowerBI Storytime Newsletter
Linkedin Profile: Linkedin
YouTube Channel: PowerBI Storytime

@olgad  - Thanks for the quick response, i need to show this for a fixed set of 30, 60, and 90 days from the last captured data set date for bl_id.

 

Thanks,

Vishant

 

Lets make it a bit more clear and take the folowing bi_id in your data set, it is the 7th of august 2023 that is the last date for this id and then we need to calculate our 30, 60, 90 from there, correct?

olgad_0-1703783177704.png

 


DID I ANSWER YOUR QUESTION? PLEASE MARK MY POST AS A SOLUTION! APPRECIATE YOUR KUDO/LIKE!
PROUD TO BE A SUPER USER!
Best Stories, Interesting Cases: PowerBI Storytime Newsletter
Linkedin Profile: Linkedin
YouTube Channel: PowerBI Storytime

@olgad  - For the given sample data set that's right and when these 30, 60, and 90 days views are created by bl_id this should always have 30, 60, and 90 days of data from the last date.

 

Thanks,

Vishant

olgad
Super User
Super User

Hi Vishant, what is the logic behind >30, ,>60 days  and are the values the %Utilization from your data?


DID I ANSWER YOUR QUESTION? PLEASE MARK MY POST AS A SOLUTION! APPRECIATE YOUR KUDO/LIKE!
PROUD TO BE A SUPER USER!
Best Stories, Interesting Cases: PowerBI Storytime Newsletter
Linkedin Profile: Linkedin
YouTube Channel: PowerBI Storytime

Hi @olgad 

 

That was a manual interpretation of the required view in excel.

 

Thanks,

Vishant

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 MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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