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
Akhil_1411
Helper IV
Helper IV

Selected value comparison not giving the exact result

 

Hi All,

 

i am trying to acheive the below logic in power bi can anyone help me

 

If my selected value date is greater than the bill date and paydate is greater than the selected value date then bill amt else 0.  But,if i apply the below logic its not giving the exact result.

 

Logic being used currently:- 

F ( MAX( Sheet1[bill_date/ Invoice date] ) < SELECTEDVALUE ( 'Date new'[Date]) && MAX(Sheet1[payment_date])>SELECTEDVALUE('Date new'[Date]),1,0)

 

 

Screenshot of applied logic: 

 

issue.png

4 REPLIES 4
v-alq-msft
Community Support
Community Support

Hi, @Akhil_1411 

 

Based on your description, I created data to reproduce your scenario.

Sheet1:

b1.png

 

Date new(a calculated table):

Date new = CALENDARAUTO()

 

There is no relationship between two tables:

 

You may create a measure as below.

IsDisplay = 
var _selecteddate = SELECTEDVALUE('Date new'[Date])
var _billdate = SELECTEDVALUE(Sheet1[bill date/Invoice date])
var _paymentdate = SELECTEDVALUE(Sheet1[payment_date])
return
IF(
    _selecteddate>_billdate&&
    _selecteddate<_paymentdate,
    1,0
)

 

Result:
b2.png

b3.png

 

 

Best Regards

Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Hi @v-alq-msft ,

 

The above logic works perfectly, the only thing is total is not calculating . Can you tell me is there anything i am missing or any suggestions.

Hi, @Akhil_1411 

 

If you want to display the right total, you may create a measure as follows.

Result = 
var _selecteddate = SELECTEDVALUE('Date new'[Date])
var tab = 
SUMMARIZE(
    Sheet1,
    Sheet1[bill date/Invoice date],
    Sheet1[payment_date],
    "flag",
    var _billdate = Sheet1[bill date/Invoice date]
    var _paymentdate = Sheet1[payment_date]
    return
    IF(
        _selecteddate>_billdate&&
        _selecteddate<_paymentdate,
        1,0
    )
)
return
SUMX(
    tab,
    [flag]
)

 

Result:

d1.png

 

Best Regards

Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-alq-msft ,

 

Thanks for your help😊

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.