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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
samoberoi
Helper II
Helper II

Subtraction with a text and date condition

HI,

I have a query on a calculation where i want to find all expenses from a column A where the values are labelled "#Authorised" and where those string values with "#Authorised" resource are within the next 3 months from a date column within the table. 

So far my calculation on creating the measure is like below

Authorised = CALCULATE([#Authorised], FILTER(Table, [#Authorised]>=TODAY()&&[#Authorised]<= EOMONTH(TODAY(),3)))
 
It gives me blank values. I don't know if this DAX is correct or not. 

Please provide some help on this.
Thanks
1 ACCEPTED SOLUTION

Hi,

Create a Calendar Table.  Create a relationship from the Date column of your data table to the Date column of the Calendar Table.  Write these measures

 

Sumexpenses = sum(Table[Expenses]
Measure for Authorsid = calculate([Sumexpense], Filter(Table, containsstring(Table[Resource], "#Authorised")
Measure  calculate([measure for authorsid],datesbetween(calendar[date],today(),eomonth([today(),3)))

 

Hope this helps.

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

7 REPLIES 7
Ahmedx
Super User
Super User

pls try this

Measure for Authorsid = calculate(Table[Sumexpense],
                      Filter(ALL(Table), containsstring(Table[Resource], "#Authorised"))

Authorised = 
            CALCULATE([#Authorised], 
                      KEEPFILTERS(FILTER(ALL(Table), 
                             [#Authorised]>=TODAY()&&[#Authorised]<= EOMONTH(TODAY(),3)))
                           )

Screenshot_1.png

Hi Ahmedx,

Thanks for your reply. However, this calculation is still giving me the total of all the values without filtering by date e.g it doesn't filter from Today till the end of March and give me the total for this duration. So, filtering doesn't take place anywhere. When i put this measure in the table visual along with the date column, it gives the same grand total amount for each individual date.

Regards,
Sam

Ritaf1983
Super User
Super User

Hi @samoberoi 

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...
Please show the expected outcome based on the sample data you provided.

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

Hi Ritaf1983,

 

 

DateResourceExpenses
24/03/2024#Authorised Milan$280.33
15/02/2024#Unauthorised Utopia$390
12/01/2024#Authorised Burma$101.20
08/12/2022#Authorised Milan$20.20
09/12/2023Pangong$1000.80
18/12/2023#Comet $550
01/01/2023#Authorised $490.51
01/01/2024#Unauthorised Belgium$280.33

 

e.g:-

Sumexpenses = calculate(sum(Table[Expenses])

 

Measure for Authorsid = calculate(Table[Sumexpense], Filter(Table, containsstring(Table[Resource], "#Authorised"

 

Now i would be interested in the calculating only the ones which have the string value #Authorised from Resource column and which are within the next 3 months from today within the table e.g it is 16/12/2023 today, it should calculate it from today till the end of March 2024 for which i tried to use following meaure, but doesn't seem to work.


Authorised = CALCULATE([#Authorised], FILTER(Table, [#Authorised]>=TODAY()&&[#Authorised]<= EOMONTH(TODAY(),3)))

 

Thanks

Hi,

Create a Calendar Table.  Create a relationship from the Date column of your data table to the Date column of the Calendar Table.  Write these measures

 

Sumexpenses = sum(Table[Expenses]
Measure for Authorsid = calculate([Sumexpense], Filter(Table, containsstring(Table[Resource], "#Authorised")
Measure  calculate([measure for authorsid],datesbetween(calendar[date],today(),eomonth([today(),3)))

 

Hope this helps.

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi Ashish,

Thanks for your response. I created the calendar table and tried to use your calculations, this calculation is still giving me the total of all the values without filtering by date e.g it doesn't filter from Today till the end of March and give me the total for this duration. So, filtering doesn't take place anywhere on this either. 

Regards,
Sam

I can help further only when i get the file.  Write my measures in that file and show the problem clearly.  Share the download link of the file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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