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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
mjanecek
Helper I
Helper I

Shifting Date Granularity: SQL Problem

I am working with an SQL Server data source concerning insurance policies query that is almost 500 lines long and has multiple CTE's some of which Left Join to the main query to achieve results.

 

This is the result for one account The number for "expiring premium including endorsements", "renewal premium including endorsements and "premiumn change including endorsements" are all correct.

 

 

 

The report calculations are all based on the month of Expiration date.  I have a request to break down what is counted by expiration date for renewed policies by bound date.  

 

I added bound date to the CTE that is returning renewals, but when a policy has more than one bound date, two lines return and the "Expiring premium including endorsements" gets counted twice and the "premiumn change including endorsements" calculation is fooled because the initial policy was not broken by 2 bound dates.

 

 

 

I need to somehow create an output that allows me to accurately count the "Expiring Premium including endorsements" only once with a DAX calculation, AND interogate teh value of the bind date to determine if the amoun in the renewal premium including endorsements should or should not be included.

 

I have been wracking my brain concerning how I may go about this and am at an impasse.

 

 

 

1 REPLY 1
lbendlin
Super User
Super User

Explore the "Group by" options in Power Query.  Use "All rows" and then grab the first row of the result for each "group".  Similar to what you would do in SQL with (select top 1 xxx from yyy)  subqueries.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.