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
John_Silva642
Frequent Visitor

CALCULATE with SELECTEDVALUE returns blank value

I want to use the Calculate with Selected value to return just one value, according to filters.

But my code doesn't work.

Below there is the DAX code and the data model

 

 

John_Silva642_0-1671634500449.png

 

John_Silva642_2-1671633405729.png

The result should be 01/08/2022, but instead, it returns BLANK. 

John_Silva642_3-1671633528762.png

 



1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your datamodel looks like, but please try below whether it suits your requirement.

 

TEST measure: =
VAR _minvalor =
    MINX (
        FILTER (
            ALLSELECTED ( 'DATABASE' ),
            'DATABASE'[Data] >= DATE ( 2022, 1, 1 )
                && 'DATABASE'[Data] <= DATE ( 2022, 11, 1 )
                && 'DATABASE'[Tipo] = "REALIZADO/TOTAL"
        ),
        'DATABASE'[Valor]
    )
RETURN
    MINX (
        FILTER (
            ALLSELECTED ( 'DATABASE' ),
            'DATABASE'[Data] >= DATE ( 2022, 1, 1 )
                && 'DATABASE'[Data] <= DATE ( 2022, 11, 1 )
                && 'DATABASE'[Tipo] = "REALIZADO/TOTAL"
                && 'DATABASE'[Valor] = _minvalor
        ),
        'DATABASE'[Data]
    )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your datamodel looks like, but please try below whether it suits your requirement.

 

TEST measure: =
VAR _minvalor =
    MINX (
        FILTER (
            ALLSELECTED ( 'DATABASE' ),
            'DATABASE'[Data] >= DATE ( 2022, 1, 1 )
                && 'DATABASE'[Data] <= DATE ( 2022, 11, 1 )
                && 'DATABASE'[Tipo] = "REALIZADO/TOTAL"
        ),
        'DATABASE'[Valor]
    )
RETURN
    MINX (
        FILTER (
            ALLSELECTED ( 'DATABASE' ),
            'DATABASE'[Data] >= DATE ( 2022, 1, 1 )
                && 'DATABASE'[Data] <= DATE ( 2022, 11, 1 )
                && 'DATABASE'[Tipo] = "REALIZADO/TOTAL"
                && 'DATABASE'[Valor] = _minvalor
        ),
        'DATABASE'[Data]
    )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Thanks a lot @Jihwan_Kim 

Works perfectly

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.