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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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