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
hosea_chumba
Helper I
Helper I

Dax Formula

Take the example below,

Please assist to come up with a formula that identifies the common items appearing in all the months. 

Date (DD/MM/YYYY)Item
01/08/2022X
03/08/2022Y
01/09/2022Z
02/09/2022X
03/09/2022Y
01/09/2022W
01/10/2022X
22/10/2022Y
01/11/2022X
11/11/2022R
23/11/2022Y
01/12/2022X
12/12/2022Y
7 REPLIES 7
tamerj1
Super User
Super User

Hi @hosea_chumba 
Apologies for the late reply.

Please refer to attached sample file and below description. Hopping this is what you're looking for.

Place the following filter measure in the filter pane of the table or chart visual and select "is" 1 or "is not blank"

1.png

Filter Measure = 
VAR T1 = CALCULATETABLE ( 'Table', ALLEXCEPT ( 'Table', 'Table'[Item] ) )
VAR T2 = SELECTCOLUMNS ( T1, "@YearMonth", FORMAT ( [Date], "YYYYMM" ) )
VAR T3 = SELECTCOLUMNS ( ALLSELECTED ('Table'[Date] ), "@YearMonth", FORMAT ( [Date], "YYYYMM" ) )
VAR REsult =
    IF ( 
        ISEMPTY ( EXCEPT ( T3, T2 ) ),
        1
    )
RETURN 
    Result
FreemanZ
Super User
Super User

hi @hosea_chumba 

I can only sovle this with a helper column. 

1) add a calculated column like:

Month = FORMAT([Date], "YYYYMM")

2) create a calculated table like this:

 

List = 
VAR _monthcount = DISTINCTCOUNT(TableName[Month])
RETURN
FILTER(
    VALUES(TableName[Item]),
    CALCULATE(DISTINCTCOUNT(TableName[Date])=_monthcount)
)

 

it worked like this:

FreemanZ_0-1674910097758.png

hi @hosea_chumba 

just realized you have in maximum one row per item every month. 

So the list - calculated table could be achieved without the helper column, like this:

List2 = 
VAR _table = 
ADDCOLUMNS(
    TableName,
    "YYYYMM",
    FORMAT(TableName[Date], "YYYYMM")
)
VAR _monthcount = COUNTROWS(SUMMARIZE(_table, [YYYYMM]))
RETURN
FILTER(
    VALUES(TableName[Item]),
    CALCULATE(DISTINCTCOUNT(TableName[Date])=_monthcount)
)

 

FreemanZ_1-1674911336287.png

hosea_chumba
Helper I
Helper I

@wdx223_Daniel unfortunately this did not work

tamerj1
Super User
Super User

Hi @hosea_chumba 

do you want to count them or display them in a crad visual or just filter a table visual or something else?

hi @tamerj1 , i want to display them in a table or a tabular visual

wdx223_Daniel
Super User
Super User

NewMeasure =
CALCULATE (
    COUNTROWS (
        SUMMARIZE (
            ADDCOLUMNS (
                VALUES ( 'Sample'[Date] ),
                "YYMM", FORMAT ( 'Sample'[Date], "YYMM" )
            ),
            [YYMM]
        )
    ),
    ALL ( 'Sample'[Date] )
)
    = CALCULATE (
        COUNTROWS (
            SUMMARIZE (
                ADDCOLUMNS (
                    VALUES ( 'Sample'[Date] ),
                    "YYMM", FORMAT ( 'Sample'[Date], "YYMM" )
                ),
                [YYMM]
            )
        ),
        ALL ( 'Sample' )
    )

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.

Top Solution Authors