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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
ctappan
Advocate III
Advocate III

measure doesn't work when using related table slicer

Hey all, looking for some assistance. I've got a Loans and PAR (All) table with unique records for each Loan ID, and this is used in lots of other visuals to filter by customer number, loan product type, etc. Then I've got a Loans and PAR (Trend) table that has a record for each day with balances and such, and there's a one to many relationship between the Loans and PAR (All) and Loans and PAR (Trend) table based on the Loan ID.

 

With some help from this board and other forums, I've put together a measure that returns the balance of the same loan from a previous period--day, week, month, quarter, year--using a comparison unit slicer. This measure works consistently and returns expected values at the totals level and at the loan level if I slice the Loans and PAR (Trend) table based on Loan ID.

 

But if I add a slicer from the Loans and PAR (All) unique-record table or other tables with relationships to the Loans and PAR (All) table, such as customer, product type, etc, the measure returns blanks rather than the expected value.

I'm including the measure formula below. I know it's a lot to look at, so thanks in advance to anyone who thinks they know why it's not working.

Previous Principal Outstanding Balance = 
    IF(HASONEVALUE('Comparison Period'[Unit]), //if no selection or multiple selections, returns "please select period." (at bottom)
        SWITCH( //like a nested IF statement; if "Day",x,if "week",y,if(...
            FIRSTNONBLANK('Comparison Period'[Unit],'Comparison Period'[Unit]),//I don't understand this
                "Day",
                IF(and(HASONEVALUE('Report Date (Daily)'[RowNum]),min('Report Date (Daily)'[RowNum]) > 1), //without this, it breaks because of first value in any record set
                    var prevWorkDay = LOOKUPVALUE('Report Date (Daily)'[Report Date],'Report Date (Daily)'[RowNum],min('Report Date (Daily)'[RowNum])-1) //get the date of the row one row less than this row
					return
                    CALCULATE(SUM('Loans and PAR (Trend)'[Principal Outstanding Balance]),'Report Date (Daily)'[Report Date] = prevWorkDay), //sum get the value where the report date is equal to the variable prevWorkDay
                    blank()
                ),
                "Week",    
                IF(AND(HASONEVALUE('Report Date (Weekly)'[Week Number]),min('Report Date (Weekly)'[RowNum]) > 1),
                    var prevWeekEnd = LOOKUPVALUE('Report Date (Weekly)'[Last Working Day of Week],'Report Date (Weekly)'[RowNum],min('Report Date (Weekly)'[RowNum])-1)
					return
                    CALCULATE(SUM('Loans and PAR (Trend)'[Principal Outstanding Balance]),'Report Date (Daily)'[Report Date] = prevWeekEnd),
                    blank()),
                "Month",
                IF(and(HASONEVALUE('Report Date (Monthly)'[RowNum]),MIN('Report Date (Monthly)'[RowNum]) > 1),
                    var prevMonthEnd = LOOKUPVALUE('Report Date (Monthly)'[Last Working Day of Month],'Report Date (Monthly)'[RowNum],min('Report Date (Monthly)'[RowNum])-1)
					return
                    CALCULATE(SUM('Loans and PAR (Trend)'[Principal Outstanding Balance]),'Report Date (Daily)'[Report Date] = prevMonthEnd),
                    blank()),
                "Quarter",
                IF(AND(HASONEVALUE('Report Date (Monthly)'[RowNum]),MIN('Report Date (Monthly)'[RowNum]) > 3),
                    var prevQtrEnd = LOOKUPVALUE('Report Date (Monthly)'[Last Working Day of Month],'Report Date (Monthly)'[RowNum],min('Report Date (Monthly)'[RowNum])-3)
					return
                    CALCULATE(SUM('Loans and PAR (Trend)'[Principal Outstanding Balance]),'Report Date (Daily)'[Report Date] = prevQtrEnd),
                    blank()),
                "Year",
                IF(and(HASONEVALUE('Report Date (Monthly)'[RowNum]),min('Report Date (Monthly)'[RowNum]) > 11),
                    var prevYearEnd = LOOKUPVALUE('Report Date (Monthly)'[Last Working Day of Month],'Report Date (Monthly)'[RowNum],min('Report Date (Monthly)'[RowNum])-12)
					return
                    CALCULATE(SUM('Loans and PAR (Trend)'[Principal Outstanding Balance]),'Report Date (Daily)'[Report Date] = prevYearEnd),
                    blank())
                    ),
                "Please select period.")
2 REPLIES 2
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @ctappan,

 

Please post some dummy data to better illustrate your scenario.

How to Get Your Question Answered Quickly

 

Regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks Yuliana.

 

Here's some basic tables and basic data.

 

Loans and PAR (All)
Loan IDProduct
1Long-Term
2Long-Term
3Short-Term
4Short-Term
5Short-Term
6Long-Term
7Long-Term
8Short-Term
9Short-Term
10

Short-Term

 

Loans and PAR (Trend) 
Loan IDBalancePrevious Balance (measure we're trying to calculate; here assuming the "daily" Unit has been selected)Report Date
1300 6/1/2018
12503006/2/2018
12002506/3/2018
15002006/4/2018
2400 6/3/2018
23004006/4/2018
22003006/5/2018
31000 6/2/2018
395010006/3/2018
39009506/4/2018
38509006/5/2018
38008506/6/2018
37508006/7/2018
4600 6/4/2018
4500600

6/5/2018

 

Report Date (Daily) 
Report DateRowNum
6/1/20181
6/2/20182
6/3/20183
6/4/20184
6/5/20185
6/6/20186
6/7/20187
6/8/20188
6/9/20189
6/10/201810

 

Comparison Unit
Unit
Daily
Weekly
Monthly
Quarterly
Yearly

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.