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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Mohan_GenZeon
Frequent Visitor

Running total with Disconnected Date Table

Hello Team,

 

I have a situation where i am trying to calcualte the running total between Date_master table to Eligmember table. but there is no any relaitonship created as this eligmember table is a scd type 2 table and having inactive relaitonship.

Here is a sample model with a few tables:

Mohan_GenZeon_0-1733231945214.png


Here is the DAX formula for one measure: based on the toggle selection

 

RegMembers_Metric_During =
SWITCH(TRUE(),
    SELECTEDVALUE(PBI_ELIGIBILITY_STATUS[STATUS]) = "At End of Selected Date Range",[RegMembers_Elig_End],
    SELECTEDVALUE(PBI_ELIGIBILITY_STATUS[STATUS])= "During Selected Date Range",[RegMembers_Elig_During])

 

RegMembers_Elig_End =
VAR _MinDate = MIN(PBI_MASTER_CALENDAR[DATE_VALUE])
VAR _MaxDate = MAX(PBI_MASTER_CALENDAR[DATE_VALUE])
RETURN                
CALCULATE(DISTINCTCOUNT(PBI_ELIGMEMBER[GUID]),
            KEEPFILTERS(PBI_ELIGMEMBER[REGISTRATION_DATE] <> BLANK()),
                KEEPFILTERS(PBI_ELIGMEMBER[REGISTRATION_DATE] >= _MinDate &&
                        PBI_ELIGMEMBER[REGISTRATION_DATE] <= _MaxDate),
                KEEPFILTERS(PBI_ELIGMEMBER[BIEFFECTIVEDATE] <= _MaxDate &&
                        PBI_ELIGMEMBER[BIENDDATE] >= _MaxDate))  

RegMembers_Elig_During =
VAR _MinDate = MIN(PBI_MASTER_CALENDAR[DATE_VALUE])
VAR _MaxDate = MAX(PBI_MASTER_CALENDAR[DATE_VALUE])
RETURN                
CALCULATE(DISTINCTCOUNT(PBI_ELIGMEMBER[GUID]),
            KEEPFILTERS(PBI_ELIGMEMBER[REGISTRATION_DATE] <> BLANK()),
                KEEPFILTERS(PBI_ELIGMEMBER[REGISTRATION_DATE] >= _MinDate &&
                        PBI_ELIGMEMBER[REGISTRATION_DATE] <= _MaxDate),
                KEEPFILTERS(PBI_ELIGMEMBER[BIEFFECTIVEDATE] <= _MaxDate &&
                        PBI_ELIGMEMBER[BIENDDATE] >= _MinDate))  


Here [MaxDate] and [MinDate] are come from the Master calendar table. And the Master calendar table has no direct relationship with Eligimember table.

See the final output of the measure

Mohan_GenZeon_0-1733232520267.png

 


Please provide suggestions for any dax queries.

Thanks
Mohan V.

1 ACCEPTED SOLUTION

Hi @Mohan_GenZeon ,

 

To modify your DAX expression to use the GUID column (string data type) instead of the amount column, you can use the COUNTROWS function to count the number of rows that match the condition. Such like below formula:

RunningTotal_ = 
VAR _MinDate = MIN(PBI_MASTER_CALENDAR[DATE_VALUE])
VAR _MaxDate = MAX(PBI_MASTER_CALENDAR[DATE_VALUE])
RETURN
COUNTROWS(
    FILTER(
        PBI_ELIGMEMBER,
        PBI_ELIGMEMBER[REGISTRATION_DATE] >= _MinDate &&
        PBI_ELIGMEMBER[REGISTRATION_DATE] <= _MaxDate &&
        PBI_ELIGMEMBER[BIEFFECTIVEDATE] <= _MaxDate &&
        PBI_ELIGMEMBER[BIENDDATE] >= _MinDate
    )
)

vkongfanfmsft_0-1734338968982.png

 

 

Best Regards,
Adamk Kong

 

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

3 REPLIES 3
Mohan_GenZeon
Frequent Visitor

@v-kongfanf-msft Thanks for the reply.

 

I have to use the GUID column here and i do not have any amount column in my table.

And FYI, guid is STRING data type column.

 

Please guide me on how i can have this expression work with STRING datatype column.

 

Apreciate your time and efforts on it.

 

Thanks,

Mohan V.

Hi @Mohan_GenZeon ,

 

To modify your DAX expression to use the GUID column (string data type) instead of the amount column, you can use the COUNTROWS function to count the number of rows that match the condition. Such like below formula:

RunningTotal_ = 
VAR _MinDate = MIN(PBI_MASTER_CALENDAR[DATE_VALUE])
VAR _MaxDate = MAX(PBI_MASTER_CALENDAR[DATE_VALUE])
RETURN
COUNTROWS(
    FILTER(
        PBI_ELIGMEMBER,
        PBI_ELIGMEMBER[REGISTRATION_DATE] >= _MinDate &&
        PBI_ELIGMEMBER[REGISTRATION_DATE] <= _MaxDate &&
        PBI_ELIGMEMBER[BIEFFECTIVEDATE] <= _MaxDate &&
        PBI_ELIGMEMBER[BIENDDATE] >= _MinDate
    )
)

vkongfanfmsft_0-1734338968982.png

 

 

Best Regards,
Adamk Kong

 

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

v-kongfanf-msft
Community Support
Community Support

Hi @Mohan_GenZeon ,

 

Maybe you can modify your formula like below:

RunningTotal = 
VAR _MinDate = MIN(PBI_MASTER_CALENDAR[DATE_VALUE])
VAR _MaxDate = MAX(PBI_MASTER_CALENDAR[DATE_VALUE])
RETURN
SUMX(
    FILTER(
        PBI_ELIGMEMBER,
        PBI_ELIGMEMBER[REGISTRATION_DATE] >= _MinDate &&
        PBI_ELIGMEMBER[REGISTRATION_DATE] <= _MaxDate &&
        PBI_ELIGMEMBER[BIEFFECTIVEDATE] <= _MaxDate &&
        PBI_ELIGMEMBER[BIENDDATE] >= _MinDate
    ),
    PBI_ELIGMEMBER[AmountColumn] 
)

vkongfanfmsft_0-1733292254976.png

 

Best Regards,
Adamk Kong

 

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

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!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.