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
Bakhtawar
Post Patron
Post Patron

dax formula

I have this formula in qliksense

(
RangeMax(0,RangeMin(( POLICY_END_DATE-POLICY_EFFECTIVE_DATE+ 1),(Date(vPE_Date) - POLICY_EFFECTIVE_DATE +1)))
)
/
(POLICY_END_DATE-POLICY_EFFECTIVE_DATE+ 1)

i am trying to rewrite this dax formula

 

vEarned_Factor = (CALCULATE(Max(0,min('Members'[POLICY_END_DATE]) - min('Members'[POLICY_EFFECTIVE_DATE])),(ENDOFQUARTER - 'Members'[POLICY_EFFECTIVE_DATE]+1))) /'Members'[POLICY_END_DATE] -  'Members'[POLICY_EFFECTIVE_DATE

 

But this some errors

 

 

any idea how to rewrite this ?

1 ACCEPTED SOLUTION

 One of them will give you result. That qlik funtion gives min max out of two, Tried that

 

measure =
var _d1 =(datediff( POLICY_END_DATE,POLICY_EFFECTIVE_DATE,day)+ 1)
var _d2 = (datediff([vPE_Date].Date,POLICY_EFFECTIVE_DATE) +1)
return

divide(if(max(_d1) <max(_d2),max(_d1),max(_d2)),max(_d1))

 

Or

measure =
var _d1 =(datediff( POLICY_END_DATE,POLICY_EFFECTIVE_DATE,day)+ 1)
var _d2 = (datediff([vPE_Date].Date,POLICY_EFFECTIVE_DATE) +1)
return

divide(if(sum(_d1) <sum(_d2),sum(_d1),sum(_d2)),sum(_d1))

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

11 REPLIES 11
amitchandak
Super User
Super User

Can you explain the logic you want?

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

this part is related to earned days .. like how much days we earned .

RangeMax(0,RangeMin(( POLICY_END_DATE-POLICY_EFFECTIVE_DATE+ 1),(Date(vPE_Date) - POLICY_EFFECTIVE_DATE +1

 

and this part is realted to total days

 

POLICY_END_DATE-POLICY_EFFECTIVE_DATE+ 1

..  @amitchandak 

@amitchandak @Icey  any help please

datediff is the function can you diff between two dates. Are these dates part the same table and same row.  The create a new column. If not. If possible please share a sample pbix file after removing sensitive information.

https://docs.microsoft.com/en-us/dax/datediff-function-dax

 

Thanks.

My Recent Blog -

https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

 

 

check files below

@amitchandak  ok now check files

 

check files from here

 

https://filebin.net/pcqilpof7hegf9ab 

Based on what I can understand

divide(if(max(_d1) <max(_d2),max(_d1),max(_d2)),max(_d1))
or
divide(if(sum(_d1) <sum(_d2),sum(_d1),sum(_d2)),sum(_d1))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak  I DID NOT UNDERSTAND

oh, something was missing

 


var _d1 =(datediff( POLICY_END_DATE,POLICY_EFFECTIVE_DATE,day)+ 1)
var _d2 = (datediff([vPE_Date].Date,POLICY_EFFECTIVE_DATE) +1)

divide(if(max(_d1) <max(_d2),max(_d1),max(_d2)),max(_d1))

divide(if(sum(_d1) <sum(_d2),sum(_d1),sum(_d2)),sum(_d1))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

these 2 should be one measure .. i dont want to seprate

 

var _d1 =(datediff( POLICY_END_DATE,POLICY_EFFECTIVE_DATE,day)+ 1)
var _d2 = (datediff([vPE_Date].Date,POLICY_EFFECTIVE_DATE) +1)

 

and what is this ?

divide(if(max(_d1) <max(_d2),max(_d1),max(_d2)),max(_d1))

divide(if(sum(_d1) <sum(_d2),sum(_d1),sum(_d2)),sum(_d1))

@amitchandak 

 One of them will give you result. That qlik funtion gives min max out of two, Tried that

 

measure =
var _d1 =(datediff( POLICY_END_DATE,POLICY_EFFECTIVE_DATE,day)+ 1)
var _d2 = (datediff([vPE_Date].Date,POLICY_EFFECTIVE_DATE) +1)
return

divide(if(max(_d1) <max(_d2),max(_d1),max(_d2)),max(_d1))

 

Or

measure =
var _d1 =(datediff( POLICY_END_DATE,POLICY_EFFECTIVE_DATE,day)+ 1)
var _d2 = (datediff([vPE_Date].Date,POLICY_EFFECTIVE_DATE) +1)
return

divide(if(sum(_d1) <sum(_d2),sum(_d1),sum(_d2)),sum(_d1))

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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.