Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
Hi,
I need help to figure how to subtract line 1 from lline 2 and so on..
is this needs to be done in a DAX formula or is there another way that can be done?
thanks
Solved! Go to Solution.
I hope I correctly understood what you are achieving. Here is a new measure
Row Difference = VAR CurrentCountry = SELECTEDVALUE('Securities Cash Flow'[County]) VAR CurrentMonth = SELECTEDVALUE('Securities Cash Flow'[Month Name]) VAR CurrentYear = SELECTEDVALUE('Securities Cash Flow'[New Biz Year]) VAR CurrentAVCount = SELECTEDVALUE('Securities Cash Flow'[AY_Count]) VAR CurrentValue = SELECTEDVALUE('Securities Cash Flow'[Mutual Funds]) VAR PreviousValue = CALCULATE( SELECTEDVALUE('Securities Cash Flow'[Mutual Funds]), FILTER( ALL('Securities Cash Flow'), 'Securities Cash Flow'[County] = CurrentCountry && 'Securities Cash Flow'[Month Name] = CurrentMonth && 'Securities Cash Flow'[New Biz Year] = CurrentYear && 'Securities Cash Flow'[AY_Count] = CurrentAVCount - 1 ) ) RETURN IF( NOT ISBLANK(CurrentValue) && NOT ISBLANK(PreviousValue), CurrentValue - PreviousValue, BLANK() )
Try this one
Year to Year Difference = VAR CurrentCountry = SELECTEDVALUE('Securities Cash Flow'[County]) VAR CurrentMonth = SELECTEDVALUE('Securities Cash Flow'[Month Name]) VAR CurrentYear = SELECTEDVALUE('Securities Cash Flow'[New Biz Year]) VAR CurrentAVCount = SELECTEDVALUE('Securities Cash Flow'[AY_Count]) VAR CurrentValue = SELECTEDVALUE('Securities Cash Flow'[Mutual Funds]) VAR PreviousYearValue = CALCULATE( SELECTEDVALUE('Securities Cash Flow'[Mutual Funds]), FILTER( ALL('Securities Cash Flow'), 'Securities Cash Flow'[County] = CurrentCountry && 'Securities Cash Flow'[Month Name] = CurrentMonth && 'Securities Cash Flow'[New Biz Year] = CurrentYear - 1 && 'Securities Cash Flow'[AY_Count] = CurrentAVCount ) ) RETURN IF( NOT ISBLANK(CurrentValue) && NOT ISBLANK(PreviousYearValue), CurrentValue - PreviousYearValue, BLANK() )
Hi @Elena_Kalina ,
I am expending this dashboard. Would it be possible to tweek this Dax to get me a year to year difference on a new table OR I need a different Dax formula?
Try this one
Year to Year Difference = VAR CurrentCountry = SELECTEDVALUE('Securities Cash Flow'[County]) VAR CurrentMonth = SELECTEDVALUE('Securities Cash Flow'[Month Name]) VAR CurrentYear = SELECTEDVALUE('Securities Cash Flow'[New Biz Year]) VAR CurrentAVCount = SELECTEDVALUE('Securities Cash Flow'[AY_Count]) VAR CurrentValue = SELECTEDVALUE('Securities Cash Flow'[Mutual Funds]) VAR PreviousYearValue = CALCULATE( SELECTEDVALUE('Securities Cash Flow'[Mutual Funds]), FILTER( ALL('Securities Cash Flow'), 'Securities Cash Flow'[County] = CurrentCountry && 'Securities Cash Flow'[Month Name] = CurrentMonth && 'Securities Cash Flow'[New Biz Year] = CurrentYear - 1 && 'Securities Cash Flow'[AY_Count] = CurrentAVCount ) ) RETURN IF( NOT ISBLANK(CurrentValue) && NOT ISBLANK(PreviousYearValue), CurrentValue - PreviousYearValue, BLANK() )
@Elena_Kalina Thank you so much, this one worked perfectly fine! Kudos to you!!
Hi,
One of ways is using visual calculation.
Please check the below picture and the attached pbix file, and I tried to create a sample pbix file like below.
Using visual calculations in Power BI Desktop - Power BI | Microsoft Learn
Hi @fbostan1
Please try to use this measure
Row Difference = VAR CurrentRowValue = SELECTEDVALUE('Securities Cash Flow'[Mutual Funds], BLANK()) VAR CurrentIndex = SELECTEDVALUE('Securities Cash Flow'[AY_COUNT]) VAR PreviousRowValue = LOOKUPVALUE( 'Securities Cash Flow'[Mutual Funds], 'Securities Cash Flow'[AY_COUNT], CurrentIndex - 1, 'Securities Cash Flow'[Month Name], SELECTEDVALUE('Securities Cash Flow'[Month Name]) ) RETURN IF( NOT ISBLANK(CurrentRowValue) && NOT ISBLANK(PreviousRowValue), CurrentRowValue - PreviousRowValue, BLANK() )
If this post helps, then please consider Accepting as solution to help the other members find it more quickly, don't forget to give a "Kudos" – I’d truly appreciate it!
Thank you.
this formula not working for me,
sorry I forgot to mention that those numbers was added from US anc CAN to get North America.
I hope I correctly understood what you are achieving. Here is a new measure
Row Difference = VAR CurrentCountry = SELECTEDVALUE('Securities Cash Flow'[County]) VAR CurrentMonth = SELECTEDVALUE('Securities Cash Flow'[Month Name]) VAR CurrentYear = SELECTEDVALUE('Securities Cash Flow'[New Biz Year]) VAR CurrentAVCount = SELECTEDVALUE('Securities Cash Flow'[AY_Count]) VAR CurrentValue = SELECTEDVALUE('Securities Cash Flow'[Mutual Funds]) VAR PreviousValue = CALCULATE( SELECTEDVALUE('Securities Cash Flow'[Mutual Funds]), FILTER( ALL('Securities Cash Flow'), 'Securities Cash Flow'[County] = CurrentCountry && 'Securities Cash Flow'[Month Name] = CurrentMonth && 'Securities Cash Flow'[New Biz Year] = CurrentYear && 'Securities Cash Flow'[AY_Count] = CurrentAVCount - 1 ) ) RETURN IF( NOT ISBLANK(CurrentValue) && NOT ISBLANK(PreviousValue), CurrentValue - PreviousValue, BLANK() )
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 |
|---|---|
| 54 | |
| 46 | |
| 44 | |
| 20 | |
| 19 |
| User | Count |
|---|---|
| 73 | |
| 71 | |
| 34 | |
| 33 | |
| 31 |