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
LeaRupnik
Helper III
Helper III

calculate with measure and filter

hello, 

 

I have two measures, one measure gives me appropriate results, one measure and the number of inappropriate results. In the table, I have a value of appropriate and inappropriate value. How can I make one measure that will be included appropriately and inappropriately according to the selected value in the column?


Thanks

1 ACCEPTED SOLUTION

Hi @LeaRupnik ,

 

According to my tests, it is possible to customize a filter. Then modify the following MEASURE formula:

M1 = 
VAR a =
    SELECTEDVALUE ( Table_slicer[Type] )
RETURN
    SWITCH (
        a,
        "x",
            CALCULATE (
                COUNTROWS ( 'Table' ),
                FILTER (
                    ALL ( 'Table' ),
                    'Table'[test] = a
                        && 'Table'[test] = MAX ( 'Table'[test] )
                )
            ),
        "ok",
            CALCULATE (
                COUNTROWS ( 'Table' ),
                FILTER (
                    ALL ( 'Table' ),
                    'Table'[test] = a
                        && 'Table'[test] = MAX ( 'Table'[test] )
                )
            )
    )
M2 = 
VAR a =
    SELECTEDVALUE ( Table_slicer[Type] )
RETURN
    SWITCH (
        a,
        "x",
            CALCULATE (
                COUNTROWS ( 'Table' ),
                FILTER (
                    ALL ( 'Table' ),
                    'Table'[test2] = a
                        && 'Table'[test2] = MAX ( 'Table'[test2] )
                )
            ),
        "ok",
            CALCULATE (
                COUNTROWS ( 'Table' ),
                FILTER (
                    ALL ( 'Table' ),
                    'Table'[test2] = a
                        && 'Table'[test2] = MAX ( 'Table'[test2] )
                )
            )
    )

vhenrykmstf_0-1637054722810.png

vhenrykmstf_1-1637054975952.pngvhenrykmstf_2-1637054988518.pngBest Regards,
Henry


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

View solution in original post

8 REPLIES 8
v-henryk-mstf
Community Support
Community Support

Hi @LeaRupnik ,

 

Based on your description, you can create the following measure and use the Edit interaction function to present your requirements:

Result = IF(MAX('Table'[test])==MAX('Table'[test2]),"uspesno","neuspesno")
M1 = CALCULATE(COUNTROWS('Table'),ALLEXCEPT('Table','Table'[test]))

M2 = CALCULATE(COUNTROWS('Table'),ALLEXCEPT('Table','Table'[test2]))

vhenrykmstf_0-1636698277761.png


If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.


Best Regards,
Henry


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

if I select "unsuccessful" in the result together, and I would compile a table with a new column where M1 = 3 in M2 = 2 can be written

 

how can I attach the attachment

thx

Hi @LeaRupnik ,

 

Measure is valued according to the filtering context, and it is not possible to combine multiple measures on the same column. It is better to see measure as a separate field to form a table visual.

vhenrykmstf_0-1636702882436.png

 


Best Regards,
Henry


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

LeaRupnik_0-1636714490879.png

i nead like this 

Hi @LeaRupnik ,

 

According to my tests, it is possible to customize a filter. Then modify the following MEASURE formula:

M1 = 
VAR a =
    SELECTEDVALUE ( Table_slicer[Type] )
RETURN
    SWITCH (
        a,
        "x",
            CALCULATE (
                COUNTROWS ( 'Table' ),
                FILTER (
                    ALL ( 'Table' ),
                    'Table'[test] = a
                        && 'Table'[test] = MAX ( 'Table'[test] )
                )
            ),
        "ok",
            CALCULATE (
                COUNTROWS ( 'Table' ),
                FILTER (
                    ALL ( 'Table' ),
                    'Table'[test] = a
                        && 'Table'[test] = MAX ( 'Table'[test] )
                )
            )
    )
M2 = 
VAR a =
    SELECTEDVALUE ( Table_slicer[Type] )
RETURN
    SWITCH (
        a,
        "x",
            CALCULATE (
                COUNTROWS ( 'Table' ),
                FILTER (
                    ALL ( 'Table' ),
                    'Table'[test2] = a
                        && 'Table'[test2] = MAX ( 'Table'[test2] )
                )
            ),
        "ok",
            CALCULATE (
                COUNTROWS ( 'Table' ),
                FILTER (
                    ALL ( 'Table' ),
                    'Table'[test2] = a
                        && 'Table'[test2] = MAX ( 'Table'[test2] )
                )
            )
    )

vhenrykmstf_0-1637054722810.png

vhenrykmstf_1-1637054975952.pngvhenrykmstf_2-1637054988518.pngBest Regards,
Henry


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

LeaRupnik
Helper III
Helper III

testtest2rezultat skupni
okokuspesno
okokuspesno
xokneuspesno
xxneuspesno
xokneuspesno
okxneuspesno
   
test1_neuspesni = 3test1_uspesni = 3
test2_neuspesni = 2test2_uspesni = 4
   
test1 nov = if(rezultat skupni = uspesno;  3, 3)
test2 nov = if(rezultat skupni = uspesno;  4, 2)

 

test1 nov and test2 nov are strangers 

 

Thx

Lea

LeaRupnik
Helper III
Helper III

LeaRupnik_0-1636541599069.png

I did the installation and i have only shown this. Please help
Greg_Deckler
Super User
Super User

@LeaRupnik Sorry, having trouble following, can you post sample data as text and expected output?
Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.