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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Dynamic Dax based on date filters

Hi, 
I'm trying to create a dynamic table based on date selection as the below DAX, but the problem is in the output where the Difference appears on both dates , not as a total difference, does anyone have a solution for this?
 
Untitled.png

DAX 

Difference =
var _max = maxx(allselected('last month GL summary'),'last month GL summary'[MIS_DATE])
var _min = minx(allselected('last month GL summary'),'last month GL summary'[MIS_DATE])
return
(calculate(SUMX(filter('last month GL summary','last month GL summary'[MIS_DATE]=_max),'last month GL summary'[USD_currency]))-calculate(SUMX( filter('last month GL summary','last month GL summary'[MIS_DATE] =_min),'last month GL summary'[USD_currency])))
 
 
1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Salam @Anonymous 

This will return the desired result under the 2nd date

Difference =
VAR PreviousDate =
    MAX ( 'last month GL summary'[MIS_DATE] ) - 1
VAR CurrentDateValue =
    SUM ( 'last month GL summary'[USD_currency] )
VAR PreviousDateValue =
    CALCULATE (
        SUM ( 'last month GL summary'[USD_currency] ),
        'last month GL summary'[MIS_DATE] = PreviousDate
    )
RETURN
    CurrentDateValue - PreviousDateValue

 

 

 

View solution in original post

7 REPLIES 7
tamerj1
Super User
Super User

Salam @Anonymous 

This will return the desired result under the 2nd date

Difference =
VAR PreviousDate =
    MAX ( 'last month GL summary'[MIS_DATE] ) - 1
VAR CurrentDateValue =
    SUM ( 'last month GL summary'[USD_currency] )
VAR PreviousDateValue =
    CALCULATE (
        SUM ( 'last month GL summary'[USD_currency] ),
        'last month GL summary'[MIS_DATE] = PreviousDate
    )
RETURN
    CurrentDateValue - PreviousDateValue

 

 

 

Anonymous
Not applicable

Thanks a lot, I fixed the equation but I still have another problem , I don't want to show the columns with Differences zero I only want to show the final difference in the matrix, Is there a solution for that?

RubaShi_0-1647941662140.png

 

@Anonymous 
Easiest way is to hide it simply using your mouse - reduce the column width to zero

Anonymous
Not applicable

Yes, but unfortunately when changing the date slicer , the columns appear again, I thought maybe creating two visuals and grouping them, if there is a better solution I would appreciate it Thanks 🙂

 

RubaShi_0-1647942523779.png

 

@Anonymous 

If you find my reply helpful kindly consider marking it as accepted solution. 

@Anonymous 

Excellent idea 👍

amitchandak
Super User
Super User

@Anonymous , if you try Day on day diff you should use date table

 

example

 

This Day = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Date]=max('Date'[Date])))
Last Day = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Date]=max('Date'[Date])-1))
Last Day = CALCULATE(sum('Table'[Qty]), previousday('Date'[Date]))

 

diff =[This Day] - [Last Day]

 

 

Day Intelligence - Last day, last non continous day
https://medium.com/@amitchandak.1978/power-bi-day-intelligence-questions-time-intelligence-5-5-5c3243d1f9

 

Why Time Intelligence Fails - Powerbi 5 Savior Steps for TI :https://youtu.be/OBf0rjpp5Hw
https://amitchandak.medium.com/power-bi-5-key-points-to-make-time-intelligence-successful-bd52912a5bd4
To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

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
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.