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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
davidressia
Regular Visitor

Card value depending which column is filtered

Hi everyone,

I have 2 different columns which are filters: Month and Quarter.

 

I also have a card which I need calculation depending which filter is applied. For example:

 

I have 2 numeric columns (Amount1 and Amount2)

If I do a month filter, so take the value Amount1 and substract Amount2 of the month.

If I do a quarter filter, I take the value of SUM(Amount1) and need substract the last value of the Quarter for Amount 2.

 

Month     -     Quarter     -     Amount1     -     Amount2

01                   1                      100                     100

02                   1                      153                     800

03                   1                      123                     400

04                   2                      543                     600

05                   2                      234                     300

06                   2                      123                     200

If I filter Month 05, so 234 - 300

If I filter Q2, so 543+234+123 - 200

 

If I filter Month 01, so 100 - 100

If I filter Q1, so 100+153+123 - 400

 

I guess is a IF but depending which table/column is filtered and active, but I cannot find nothing.

 

Thanks!!

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

 

Slide1.jpg

 

Expected result measure: =
SWITCH (
    TRUE (),
    HASONEFILTER ( Data[Month] ), SUM ( Data[AmountOne] ) - SUM ( Data[AmountTwo] ),
    HASONEFILTER ( Data[Quarter] ),
        SUM ( Data[AmountOne] )
            - CALCULATE (
                SUM ( Data[AmountTwo] ),
                FILTER ( VALUES ( Data[Month] ), Data[Month] = MAX ( Data[Month] ) )
            )
)

 

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.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

View solution in original post

1 REPLY 1
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

 

Slide1.jpg

 

Expected result measure: =
SWITCH (
    TRUE (),
    HASONEFILTER ( Data[Month] ), SUM ( Data[AmountOne] ) - SUM ( Data[AmountTwo] ),
    HASONEFILTER ( Data[Quarter] ),
        SUM ( Data[AmountOne] )
            - CALCULATE (
                SUM ( Data[AmountTwo] ),
                FILTER ( VALUES ( Data[Month] ), Data[Month] = MAX ( Data[Month] ) )
            )
)

 

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.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.