Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowGet inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.
Hello, I have a very complicated problem. Thank you for your help.
I have two tables in Power BI called Date and Invoice that are related
Now I want to calculate the DateDiff column in the invoice table as follows:
Using the date table and the month column, we create a date filter on the page.
There are two modes
1- The user has not selected the month, in this case:
DateDiff = date[invoice] - today()
Of course, this number must be the smallest number for each customer, for example, for customer number 10
11/28/2023-11/1/2023 =27
2- The user selects the date of the month using the table:
In this case, Today() is equal to the first day of the month selected by the user, and then the DateDiff calculation changes according to the user's selection.
Solved! Go to Solution.
hi, @JavidRobatian
try below code
Measure =
var a = SELECTEDVALUE('date'[month])
var b = DATEDIFF(CALCULATE(min(invoice[date]),ALLEXCEPT(invoice,invoice[cu nu])),TODAY(),DAY)
var c = DATEDIFF(CALCULATE(min(invoice[date]),ALLEXCEPT(invoice,invoice[cu nu])),DATE(2023,a,1),DAY)
var d = IF(ISFILTERED('date'[month]),c,b)
return
d
hi, @JavidRobatian
try below code
Measure =
var a = SELECTEDVALUE('date'[month])
var b = DATEDIFF(CALCULATE(min(invoice[date]),ALLEXCEPT(invoice,invoice[cu nu])),TODAY(),DAY)
var c = DATEDIFF(CALCULATE(min(invoice[date]),ALLEXCEPT(invoice,invoice[cu nu])),DATE(2023,a,1),DAY)
var d = IF(ISFILTERED('date'[month]),c,b)
return
d
If the explanation is not clear, please tell me so that I can explain more.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the February 2025 Power BI update to learn about new features.
User | Count |
---|---|
23 | |
12 | |
10 | |
10 | |
8 |
User | Count |
---|---|
16 | |
15 | |
15 | |
12 | |
10 |