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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
SteCra100
Helper I
Helper I

A Percentage Measure using just Fiscal date data

Hello folks. First of all, I just want to say how helpful the PowerBI Community has. They have been able to help me on so many occasions.  I can’t thank you enough!

 

I have a query, which I hope someone will be able to answer…

 

We have a fiscal year, which runs from 01 April 2020 to 31 March 2021. I have two columns:

 

Task Completed/Incompleted on Time

 

Date

 

The “Task Completed/Incompleted on Time” column just displays either 1 or zero. If the result set is 1, then the “Task” is completed on time.

 

Zero means the Task has been completed, but completed outwith the time set.

 

The “Date” column is just a date of when the task was completed.

 

I want to be able to create a percentage measure that displays any results that are 1. I have created a measure like below:

 

% YES =

DIVIDE (

    CALCULATE ( COUNT ( TableName[Tasks Completed/Incompleted on Time] ),

TableName[Tasks Completed/Incompleted on Time = "1" ),

    CALCULATE ( COUNT TableName[Tasks Completed/Incompleted on Time] ), ALLSELECTED ( TableName[Tasks Completed/Incompleted on Time)] ) )

)

 

The above is formatted to Percentage. But the above calculates all the Tasks that are equal to “1”, I just want to calculate Tasks that are equal to “1”, within the date range of 01 April 2020 to 31 March 2021.

 

Is there a way to do this?

 

Many thanks,

1 ACCEPTED SOLUTION

@SteCra100 
You had double commas in the 2nd Calculate function. You may also try use / instead of divide() for easy reading. Try:

%Completed on Time = 
CALCULATE( COUNT ( InsertTableNameHere[Tasks Completed/Incompleted on Time] ),DATESYTD('InsertColumnNameHere'.[Date],"31/03/2031 23:59:00"),Filter(InsertTableNameHere,
InsertTableNameHere[Tasks Completed/Incompleted on Time = "1") ) 
/
CALCULATE( COUNT ( InsertTableNameHere[Tasks Completed/Incompleted on Time] ),
DATESYTD('InsertColumnNameHere'.[Date],"31/03/2031 23:59:00")))


Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

@SteCra100 , Try a measure like

% YES = divide(CALCULATE( COUNT ( TableName[Tasks Completed/Incompleted on Time] ),DATESYTD('Date'[Date],"3/31"),TableName[Tasks Completed/Incompleted on Time = "1") ,CALCULATE( COUNT ( TableName[Tasks Completed/Incompleted on Time] ),,DATESYTD('Date'[Date],"3/31")))

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

Hello @amitchandak 

 

Many thanks for your quick reply and thank you for your measure syntax. I have used the following syntax for my measure:


%Completed on Time = divide(CALCULATE( COUNT ( InsertTableNameHere[Tasks Completed/Incompleted on Time] ),

DATESYTD('InsertColumnNameHere'.[Date],"31/03/2031 23:59:00"),

InsertTableNameHere[Tasks Completed/Incompleted on Time = "1") ,

CALCULATE( COUNT ( InsertTableNameHere[Tasks Completed/Incompleted on Time] ),,

DATESYTD('InsertColumnNameHere'.[Date],"31/03/2031 23:59:00")))

 

However, I get a error:

 

"Argument '2' in CALCULATE function is required."

 

I'm not quite sure what this error means? Does this mean I need another argument in the syntax above?

 

Many thanks,

@SteCra100 
You had double commas in the 2nd Calculate function. You may also try use / instead of divide() for easy reading. Try:

%Completed on Time = 
CALCULATE( COUNT ( InsertTableNameHere[Tasks Completed/Incompleted on Time] ),DATESYTD('InsertColumnNameHere'.[Date],"31/03/2031 23:59:00"),Filter(InsertTableNameHere,
InsertTableNameHere[Tasks Completed/Incompleted on Time = "1") ) 
/
CALCULATE( COUNT ( InsertTableNameHere[Tasks Completed/Incompleted on Time] ),
DATESYTD('InsertColumnNameHere'.[Date],"31/03/2031 23:59:00")))


Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.

 

Hello @V-pazhen-msft 

 

I tweaked the measure slightly to work for me, but I got the result I desire for. Thank you!

 

Many thanks,

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.