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

Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more

Reply
LeroyPaul
Helper I
Helper I

Workflow dynamic variable in calculated column

Hello ! 🙂

I would like your help with a workflow dashboard project.

For this project, I need to track the processing of support tickets.

I have a database with different dates that allow me to track the processing of each ticket at each stage (a ticket creation date, a start date for each stage, an end date for each stage), as well as a status to determine whether or not the ticket is closed.

 

Here's an example of a ticket:

 

workflowId

workflowStepId

creationDate

workflowStepNo

startDate

endDate

workflowStatusName

81542

25120

10/07/2023

1

10/07/2023

16/07/2023

Completed

81542

25121

10/07/2023

2

16/07/2023

17/07/2023

Completed

81542

25122

10/07/2023

3

17/07/2023

18/07/2023

Completed

81542

25123

10/07/2023

4

18/07/2023

19/07/2023

Completed

81542

25124

10/07/2023

5

19/07/2023

20/07/2023

Completed

81542

25125

10/07/2023

6

20/07/2023

21/07/2023

Completed

81542

25126

10/07/2023

7

21/07/2023

22/07/2023

Completed

81542

25127

10/07/2023

8

22/07/2023

23/07/2023

Completed

81542

25128

10/07/2023

9

23/07/2023

24/07/2023

Completed

81542

25129

10/07/2023

10

24/07/2023

25/07/2023

Completed

 

I've created a Calendar=CALENDARAUTO() table that has no relationships, in order to filter my data.

 

Using a slicer filter in the dashboard, I select a period between two dates in my Calendar table.

I retrieve the information from this selected range and try to determine :

  • the stock of tickets to be processed before my period
  • the stock of new tickets on my period
  • the stock of tickets closed on my period
  • the stock remaining after this period

I've managed to achieve these 4 measures by creating a grouped table with one row per ticket, and by determining that the maximum end date for a ticket corresponds to the ticket's closure date if the ticket has a closed status.

NumberOfCasesStart = Number of tickets to be processed at the start of the period (=number of tickets created before the selected period and not closed before the end of the selected period).

NumberOfNewCases = Number of new tickets during the period

NumberOfCloseCases= Number of tickets closed during period

NumberOfCasesEnd = Number of tickets remaining to be processed at the end of the period (=number of tickets not closed + tickets closed after the end of the selected period).

 

Now I'd like to determine which processing stage my ticket is in. To do this, I've created 2 calculated columns, but they don't work as I'd like.

 

I want to create the StepCasesStart column to determine, at the start of the selected period, which processing step my ticket is in. This means that I'm looking for the Maximum StartDate of the ticket being lower than the minimum date selected on my period.

 

I've made this calculated column DAX formula:

StepCasesStart =

VAR steptest =

CALCULATE(

    MAX( 'Workflows Cases Detailed'[startDate]),

    FILTER(ALLEXCEPT('Workflows Cases Detailed','Workflows Cases Detailed'[workflowId]),

            'Workflows Cases Detailed'[startDate]<= [Min Calendar]

    )

)

RETURN

IF('Workflows Cases Detailed'[startDate]=steptest&&NOT ISBLANK('Workflows Cases Detailed'[startDate]),1,0)

 

I also want to find out which processing stage my ticket is in at the end of the selected period. This means that I'm looking for the Maximum StartDate of the ticket being less than the maximum date selected on my period and that the EndDate of this step is either empty or greater than my selected period.

 

I made this calculated column DAX formula:

StepCasesEnd =

VAR maxperid =

CALCULATE(

    MAX( 'Workflows Cases Detailed'[startDate]),

    FILTER(ALLEXCEPT('Workflows Cases Detailed','Workflows Cases Detailed'[workflowId]),

            'Workflows Cases Detailed'[startDate]<= [Max Calendar]

    )

)

VAR maxperid2 =

CALCULATE(

    MIN( 'Workflows Cases Detailed'[endDate]),

    FILTER(ALLEXCEPT('Workflows Cases Detailed','Workflows Cases Detailed'[workflowId]),

            'Workflows Cases Detailed'[endDate]>[Max Calendar]

    )

)

RETURN

IF('Workflows Cases Detailed'[startDate]=maxperid&&(ISBLANK('Workflows Cases Detailed'[endDate])||'Workflows Cases Detailed'[endDate]=maxperid2),1,0)

 

Can you help me figure out how to make this calculated column work, or do you know of another method that would work? I know it's very complicated to work with dynamic variables on Power BI.

I am attaching the Power BI file.

https://www.dropbox.com/scl/fi/xexzii4hjdyo5xf10b393/Workflow.pbix?rlkey=f19lte7vzjb47jjjw61cymlsp&d...

Thanks you in advance !

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

You cannot create calculated columns from measures or slicers. You need to create new measures.

View solution in original post

2 REPLIES 2
lbendlin
Super User
Super User

You cannot create calculated columns from measures or slicers. You need to create new measures.

In fact, I've got around the problem by using measurements. Thanks for your help!

Helpful resources

Announcements
PBIApril_Carousel

Power BI Monthly Update - April 2025

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

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

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

Top Solution Authors