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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Anonymous
Not applicable

Reffering to [Value] of GENERATESERIES within Variables

I have a table that contains transactions done by users. Beside the user and the date, the transaction was created on, the table contains several other information like the users team lead, the project and process the transaction was made for, etc.

 

I now want to create a measure that calculates the average amount of transactions created within a selected periode by users with the same attribute (same project, same team lead, etc.). So the basic calculation would be (average transactions per day) / (average amount of users per day).

This is my approach:

av_Transactions_timeperiode = 

VAR start_date = IF(ISBLANK(MIN('Merged Data'[Created_Date])),0,MIN('Merged Data'[Created_Date]))
VAR end_date = IF(ISBLANK(MAX('Merged Data'[Created_Date])),1,MAX('Merged Data'[Created_Date]))

VAR __dates = GENERATESERIES(start_date,end_date)

VAR __trans_users = ADDCOLUMNS(__dates,
                                "Transactions",
                                CALCULATE(COUNT('Merged Data'[TransactionID]),'Merged Data'[Created_Date] = [Value]),
                                "Users",
                                CALCULATE(DISTINCTCOUNT('Merged Data'[User]),'Merged Data'[Created_Date] = [Value])
                            )

VAR av_transactions = AVERAGEX(__trans_users,[Transactions])
VAR av_users = AVERAGEX(__trans_users,[Users])

VAR av_trans_per_user = av_transactions/av_users

RETURN av_trans_per_user


However this doesn't work. Within the ADDCOLUMNS I can reffer to the [Value] of __dates but as soon as I want to reffer to it within the CALCULATE function it cannot be found. There is no difference when I try to use "__dates[Value]" instead, as __dates is a variable and not a "manifestated" table.

Is there any option I could reffer to the [Value] of __dates within the CALCULATE function? Or is there another approach to calculate the data I want?

If needed: The table "Merged Data" is sliced by a seperate date table that is related via the "Created_Date" column.

Thanks in advance

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @Anonymous 

please try

av_Transactions_timeperiode =
VAR start_date =
COALESCE ( MIN ( 'Merged Data'[Created_Date] ), 0 )
VAR end_date =
COALESCE ( MAX ( 'Merged Data'[Created_Date] ), 1 )
VAR __dates =
CALENDAR ( start_date, end_date )
VAR __trans_users =
GENERATE (
__dates,
VAR CurrentDate = [Date]
VAR Transactions =
CALCULATE (
COUNT ( 'Merged Data'[TransactionID] ),
'Merged Data'[Created_Date] = CurrentDate
)
VAR Users =
CALCULATE (
DISTINCTCOUNT ( 'Merged Data'[User] ),
'Merged Data'[Created_Date] = CurrentDate
)
RETURN
ROW ( "Transactions", Transactions, "Users", Users )
)
VAR av_transactions =
AVERAGEX ( __trans_users, [Transactions] )
VAR av_users =
AVERAGEX ( __trans_users, [Users] )
VAR av_trans_per_user = av_transactions / av_users
RETURN
av_trans_per_user

View solution in original post

2 REPLIES 2
tamerj1
Super User
Super User

Hi @Anonymous 

please try

av_Transactions_timeperiode =
VAR start_date =
COALESCE ( MIN ( 'Merged Data'[Created_Date] ), 0 )
VAR end_date =
COALESCE ( MAX ( 'Merged Data'[Created_Date] ), 1 )
VAR __dates =
CALENDAR ( start_date, end_date )
VAR __trans_users =
GENERATE (
__dates,
VAR CurrentDate = [Date]
VAR Transactions =
CALCULATE (
COUNT ( 'Merged Data'[TransactionID] ),
'Merged Data'[Created_Date] = CurrentDate
)
VAR Users =
CALCULATE (
DISTINCTCOUNT ( 'Merged Data'[User] ),
'Merged Data'[Created_Date] = CurrentDate
)
RETURN
ROW ( "Transactions", Transactions, "Users", Users )
)
VAR av_transactions =
AVERAGEX ( __trans_users, [Transactions] )
VAR av_users =
AVERAGEX ( __trans_users, [Users] )
VAR av_trans_per_user = av_transactions / av_users
RETURN
av_trans_per_user

Anonymous
Not applicable

Thanks @tamerj1 ,

 

this works as intended.

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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