Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreWe've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now
Hello,
I'm using the above DAX to get selected month values and same period last year value of the selected date and I want now to calculate the difference between the 2. Below is the result from above DAX.
I need to calculate difference between the two dates, 11/30/2023 being selected date and 11/22/2022 being start date.
Solved! Go to Solution.
Hi @DianeUmu ,
You can try the following Dax.
Test =
var _mindate=
IF(
[SMRR Gain]=BLANK(),BLANK(),
MINX(FILTER(ALLSELECTED('vm_fct_store_month_360'),[SMRR Gain]<>BLANK()),[LAST_CALENDAR_DATE]))
var _maxdate=
IF(
[SMRR Gain]=BLANK(),BLANK(),
MAXX(FILTER(ALLSELECTED('vm_fct_store_month_360'),[SMRR Gain]<>BLANK()),[LAST_CALENDAR_DATE]))
return
SUMX( FILTER(ALLSELECTED('vm_fct_store_month_360'),'vm_fct_store_month_360'[LAST_CALENDAR_DATE]=_mindate),[SMRR Gain])
-
SUMX( FILTER(ALLSELECTED('vm_fct_store_month_360'),'vm_fct_store_month_360'[LAST_CALENDAR_DATE]=_maxdate),[SMRR Gain])
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 @DianeUmu ,
You can try the following Dax.
Test =
var _mindate=
IF(
[SMRR Gain]=BLANK(),BLANK(),
MINX(FILTER(ALLSELECTED('vm_fct_store_month_360'),[SMRR Gain]<>BLANK()),[LAST_CALENDAR_DATE]))
var _maxdate=
IF(
[SMRR Gain]=BLANK(),BLANK(),
MAXX(FILTER(ALLSELECTED('vm_fct_store_month_360'),[SMRR Gain]<>BLANK()),[LAST_CALENDAR_DATE]))
return
SUMX( FILTER(ALLSELECTED('vm_fct_store_month_360'),'vm_fct_store_month_360'[LAST_CALENDAR_DATE]=_mindate),[SMRR Gain])
-
SUMX( FILTER(ALLSELECTED('vm_fct_store_month_360'),'vm_fct_store_month_360'[LAST_CALENDAR_DATE]=_maxdate),[SMRR Gain])
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.
Liu, The formula worked, However I want to have the difference between the two dates in the same measure and the output should look like this
Basically have differenece value next to 11/30/2023.
Please advice.
And using the formula that you provided, It's giving me the same amount for the 2 dates without the difference.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |