Forum Discussion
Power BI M-Query to Compare Dates
- Anonymous5 years ago
Hi Shankar_BI ,
It would be better to use the Dax function
I created some data:
Table:
Date Table:
1. Create measure.
Ever on payroll = var _Currentvalue=SELECTEDVALUE('Date'[Current Selected month value]) var _count1=COUNTAX(FILTER(ALL('Table'),'Table'[Joining Date of Employee]<DATE(YEAR(_Currentvalue),MONTH(_Currentvalue)+1,DAY(_Currentvalue))),'Table'[Employee]) var _count2=COUNTAX(FILTER(ALL('Table'),'Table'[Separation Date of Employees]<_Currentvalue),'Table'[Employee]) var _count3=COUNTAX(FILTER(ALL('Table'),'Table'[Employee Status Date]<_Currentvalue&&'Table'[Employee Status]="Suspended - Was previously on pay roll"),'Table'[Employee]) return _count1-_count2+_count32. Use [Current Selected month value] of the Date table as the slicer
3. Result:
If the answer is not what you expected, can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Shankar_BI ,
This error occurs because you did not click on the value in the slicer, the correct value will be displayed after clicking
The measure cannot be put into the slicer, you can put the date field into the slicer, and use the Multi-row card to put the three measures together to display
You said that the report can display monthly values as well as QTD, LTD.... This seems to be inconsistent with your Excel formula above. Can you describe it?
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thank you!!
I am able to fix this issue.
Best Regards