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
Anonymous
Not applicable

Based my emailid(loginuser) line chart

Hi Team,

Please anybody help me to write DAX formula.

I have below columns

NameEmailIDHospitalNameCityNameDateAmount

 

I need create below Checkbox

Vedantika_0-1657035175041.png

 

please anybody help how to create this checkbox Me mean how login ,MyHospital mean login user hosiptal

 

I need create Linechart x-axis is Year and Y-axis Amount

 

if I can select Me checck then show line in chart

if i can select MyHosital we need show line my enter hospital where I am working(example if I am working XYZ hospital only XYZ sum of  amount)

if I can select myCity we need show line my city(example I am working ABC city only sum of ABC city not other city)

 

 

please anybody can help how to create checkbox based loginuser (Me),loginuser Hospital(MyHosital),login user city(Mycity).

and also need show line chart based on selection

if i am select 3 checkbox i need show 3 different lines.

 

Thanks

Vedantika

1 ACCEPTED SOLUTION
v-chenwuz-msft
Community Support
Community Support

Hi @Anonymous ,

 

Maybe you can try these steps to do that.

 

1 Create a table named line via 

Line = {"My","Myhospital","Mycity"}

2 Create there measures as the following:

My =
VAR _1 =
    CALCULATE (
        SUM ( 'Table'[amount] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            [EmailID] = SELECTEDVALUE ( user[EmailID] )
                && [DATE].[Year] = YEAR ( MAX ( 'Table'[DATE] ) )
        )
    )
RETURN
    IF (
        ISFILTERED ( 'Line'[LineName] )
            && CONTAINSROW ( VALUES ( 'Line'[LineName] ), "My" ),
        _1,
        BLANK ()
    )

MyC =
VAR _1 =
    CALCULATE (
        SUM ( 'Table'[amount] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            [DATE].[Year] = YEAR ( MAX ( 'Table'[DATE] ) )
                && [CityName]
                    IN CALCULATETABLE (
                        VALUES ( 'Table'[CityName] ),
                        FILTER ( ALLSELECTED ( 'Table' ), [EmailID] = SELECTEDVALUE ( user[EmailID] ) )
                    )
        )
    )
RETURN
    IF (
        ISFILTERED ( 'Line'[LineName] )
            && CONTAINSROW ( VALUES ( 'Line'[LineName] ), "Mycity" ),
        _1
    )

MyH =
VAR _1 =
    CALCULATE (
        SUM ( 'Table'[amount] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            [DATE].[Year] = YEAR ( MAX ( 'Table'[DATE] ) )
                && [HospitalName]
                    IN CALCULATETABLE (
                        VALUES ( 'Table'[HospitalName] ),
                        FILTER ( ALLSELECTED ( 'Table' ), [EmailID] = SELECTEDVALUE ( user[EmailID] ) )
                    )
        )
    )
RETURN
    IF (
        ISFILTERED ( 'Line'[LineName] )
            && CONTAINSROW ( VALUES ( 'Line'[LineName] ), "Myhospital" ),
        _1
    )

 

Result:

 

vchenwuzmsft_1-1657272544567.gif

 

Pbix in the end you can refer.

Best Regards

Community Support Team _ chenwu zhu

 

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

1 REPLY 1
v-chenwuz-msft
Community Support
Community Support

Hi @Anonymous ,

 

Maybe you can try these steps to do that.

 

1 Create a table named line via 

Line = {"My","Myhospital","Mycity"}

2 Create there measures as the following:

My =
VAR _1 =
    CALCULATE (
        SUM ( 'Table'[amount] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            [EmailID] = SELECTEDVALUE ( user[EmailID] )
                && [DATE].[Year] = YEAR ( MAX ( 'Table'[DATE] ) )
        )
    )
RETURN
    IF (
        ISFILTERED ( 'Line'[LineName] )
            && CONTAINSROW ( VALUES ( 'Line'[LineName] ), "My" ),
        _1,
        BLANK ()
    )

MyC =
VAR _1 =
    CALCULATE (
        SUM ( 'Table'[amount] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            [DATE].[Year] = YEAR ( MAX ( 'Table'[DATE] ) )
                && [CityName]
                    IN CALCULATETABLE (
                        VALUES ( 'Table'[CityName] ),
                        FILTER ( ALLSELECTED ( 'Table' ), [EmailID] = SELECTEDVALUE ( user[EmailID] ) )
                    )
        )
    )
RETURN
    IF (
        ISFILTERED ( 'Line'[LineName] )
            && CONTAINSROW ( VALUES ( 'Line'[LineName] ), "Mycity" ),
        _1
    )

MyH =
VAR _1 =
    CALCULATE (
        SUM ( 'Table'[amount] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            [DATE].[Year] = YEAR ( MAX ( 'Table'[DATE] ) )
                && [HospitalName]
                    IN CALCULATETABLE (
                        VALUES ( 'Table'[HospitalName] ),
                        FILTER ( ALLSELECTED ( 'Table' ), [EmailID] = SELECTEDVALUE ( user[EmailID] ) )
                    )
        )
    )
RETURN
    IF (
        ISFILTERED ( 'Line'[LineName] )
            && CONTAINSROW ( VALUES ( 'Line'[LineName] ), "Myhospital" ),
        _1
    )

 

Result:

 

vchenwuzmsft_1-1657272544567.gif

 

Pbix in the end you can refer.

Best Regards

Community Support Team _ chenwu zhu

 

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

 

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.