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
kamburn
New Member

Measure calculates correctly until related table field is added then duplicates

Hi All-

 

I have a measure that is used to calulcate the last date record before a specific date. This measure works correctly as long as all of my fields are from the original table. However, if I add a field from a dimension table (relationship 1-many) the two tables duplicate all the values. The relationship also works fine when I do not have the measure added.

 

My Measure is: 

 

Is Last Before Selection = 
var tbl1 = CALCULATETABLE(Filter(FactForecasts2, FactForecasts2[Date] <= [Selected Allocation Date]), ALLEXCEPT(FactForecasts2, FactForecasts2[Item], FactForecasts2[Group]))
var maxDate = MAXX(tbl1, [Date])
return calculate(maxDate = Max([Date]))

 

Selected Allocation Date is also a measure getting the date from a slicer:

 

Selected Allocation Date = VALUES(Dates[Date])

 

 

On the report in Power BI I have 3 visuals.

  1. All fields in the same FactForecasts table. The values of true in green boxes are correct.
  2. No measure, but the first Group is from DimProductGroups and the second is from FactForecasts and they are Related on that field with 1 to Many. This also looks correct
  3. This is the same as #2, but the Measue "Is Last Before Selection" is added. The rows are duplicated with each of the groups being aligned as if not related. The red box shows values where it has Group1 from one table and Group2 from the other table. Excluding these red boxes, the actual measue still works correctly where the two groups are actually correctly aligned.

powerbimeasure.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

The data that I have created is pretty simple.

 

DimProducts

GroupDescription
Group1Description 1
Group2Description 2

 

FactForecasts

GroupItemDateQtyOther
Group1Item144927100X
Group1Item145078110Y
Group1Item14520090Z
Group1Item24507880A
Group1Item24517070B
Group2Item144928101XX
Group2Item145079102YY
Group2Item145201103ZZ

 

Dates (For the slicer)

Date
1/15/2023
7/15/2023
10/15/2023

 

Thanks in advance for any insight.

0 REPLIES 0

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.