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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
YYlee
Helper I
Helper I

DAX Questions

Question 1:

consol Amount =
VAR SelectedCurrency =
    SWITCH(
        TRUE(),
        SELECTEDVALUE(Revenue[Location]) = "Group" || ISBLANK(SELECTEDVALUE(Revenue[Location])), "USD",
        SELECTEDVALUE(Revenue[Location]) = "Hong Kong", "HKD",
        SELECTEDVALUE(Revenue[Location]) = "Singapore", "SGD",
        SELECTEDVALUE(Revenue[Location]) = "Shanghai", "CNY",
        BLANK()
    )

VAR Amount =
    SWITCH(
        TRUE(),
        SelectedCurrency = "USD",
            -- Use TREATAS to map Revenue[Location] to Consolidated (2)[Location]
            CALCULATE(SUM('Consolidated (2)'[Amount Invoiced (USD)]),
                      TREATAS({"Hong Kong", "Singapore", "Shanghai"}, 'Consolidated (2)'[Location])),
        SelectedCurrency = "HKD",
            CALCULATE(SUM('Consolidated (2)'[Amount Invoiced (USD)]),
                      TREATAS({"Hong Kong"}, 'Consolidated (2)'[Location])),
        SelectedCurrency = "SGD",
            CALCULATE(SUM('Consolidated (2)'[Amount Invoiced (USD)]),
                      TREATAS({"Singapore"}, 'Consolidated (2)'[Location])),
        SelectedCurrency = "CNY",
            CALCULATE(SUM('Consolidated (2)'[Amount Invoiced (USD)]),
                      TREATAS({"Shanghai"}, 'Consolidated (2)'[Location])),
        BLANK()
    )
RETURN
    Amount
 
I try to group them up and get a Top 5 client list and $$. All works EXCEPT when I filter "Group", does not show data at all. 

Question 2: 
Can I have a 5 year trends of 2024 client list trends? When I click on Top 5, I believe it will count on Total clients and provide me a 5 years trends.

Question 3. I have a line and cluster chart as below:
My line chart show as a dot instead of line, I understand that I might have filter the year of "2024" and the Excel only have 1 data. What can I do to make it to a straight line for more clear vision?
YYlee_0-1736787803141.png

 

3 REPLIES 3
AmiraBedh
Super User
Super User

Question 1 :

I think that the issue is how the TREATAS function is used for "Group" because it is attempting to filter the Location column in Consolidated (2) for "Hong Kong", "Singapore", and "Shanghai". However, when "Group" is selected, the TREATAS might not properly evaluate the aggregated locations.

You need to handle the "Group" selection explicitly by summing all locations without filtering:

SelectedCurrency = "USD" && SELECTEDVALUE(Revenue[Location]) = "Group",
CALCULATE(
    SUM('Consolidated (2)'[Amount Invoiced (USD)])
),

Updated DAX Measure:

consol Amount =
VAR SelectedCurrency =
    SWITCH(
        TRUE(),
        SELECTEDVALUE(Revenue[Location]) = "Group" || ISBLANK(SELECTEDVALUE(Revenue[Location])), "USD",
        SELECTEDVALUE(Revenue[Location]) = "Hong Kong", "HKD",
        SELECTEDVALUE(Revenue[Location]) = "Singapore", "SGD",
        SELECTEDVALUE(Revenue[Location]) = "Shanghai", "CNY",
        BLANK()
    )

VAR Amount =
    SWITCH(
        TRUE(),
        SelectedCurrency = "USD" && SELECTEDVALUE(Revenue[Location]) = "Group",
            CALCULATE(
                SUM('Consolidated (2)'[Amount Invoiced (USD)])
            ),
        SelectedCurrency = "USD",
            CALCULATE(
                SUM('Consolidated (2)'[Amount Invoiced (USD)]),
                TREATAS({"Hong Kong", "Singapore", "Shanghai"}, 'Consolidated (2)'[Location])
            ),
        SelectedCurrency = "HKD",
            CALCULATE(SUM('Consolidated (2)'[Amount Invoiced (USD)]),
                      TREATAS({"Hong Kong"}, 'Consolidated (2)'[Location])),
        SelectedCurrency = "SGD",
            CALCULATE(SUM('Consolidated (2)'[Amount Invoiced (USD)]),
                      TREATAS({"Singapore"}, 'Consolidated (2)'[Location])),
        SelectedCurrency = "CNY",
            CALCULATE(SUM('Consolidated (2)'[Amount Invoiced (USD)]),
                      TREATAS({"Shanghai"}, 'Consolidated (2)'[Location])),
        BLANK()
    )
RETURN
    Amount

Question 2: 

Create a measure to dynamically calculate the top 5 clients based on total revenue:

Top 5 Clients Revenue =
CALCULATE(
    [consol Amount], -- Assuming this is the main measure
    TOPN(5, VALUES('Clients'[Client Name]), [consol Amount], DESC)
)

Then create a Line Chart for 5-Year Trends.


Question 3:

This happens because you only have one data point for the year "2024."

You can add dummy data for example, you can add rows with zero values for each month or quarter.

or you modify your measure to fill gaps with previous data:

Fill Gaps Measure =
IF(
    ISBLANK([consol Amount]),
    CALCULATE(
        [consol Amount],
        FILTER(
            ALL('Date'),
            'Date'[Date] < MAX('Date'[Date])
        )
    ),
    [consol Amount]
)

If adding data points isn't possible, you can use a "smoothed" line chart or consider a different visualization that does not depend on continuous data (like a bar chart).


Proud to be a Power BI Super User !

Microsoft Community : https://docs.microsoft.com/en-us/users/AmiraBedhiafi
Linkedin : https://www.linkedin.com/in/amira-bedhiafi/
StackOverflow : https://stackoverflow.com/users/9517769/amira-bedhiafi
C-Sharp Corner : https://www.c-sharpcorner.com/members/amira-bedhiafi
Power BI Community :https://community.powerbi.com/t5/user/viewprofilepage/user-id/332696

Thank you. 
Q1 solved. 
Q2 supposed based on Q1+Year 2024 only = Top 5 list. 
their trend suppose shown from 2020-2024
Q3. May I ask what is a dummy data? I have 4 categories in Year 2024, and they share the same amount of line y-axis based on location. 
For eg, Group is 40%, Hong Kong is 27%, Shanghai ... Singapore ...But they are not different by the y-axis categories

Can you clarify more your questions regarding Q2 and Q3? if possible can you share some data please?


Proud to be a Power BI Super User !

Microsoft Community : https://docs.microsoft.com/en-us/users/AmiraBedhiafi
Linkedin : https://www.linkedin.com/in/amira-bedhiafi/
StackOverflow : https://stackoverflow.com/users/9517769/amira-bedhiafi
C-Sharp Corner : https://www.c-sharpcorner.com/members/amira-bedhiafi
Power BI Community :https://community.powerbi.com/t5/user/viewprofilepage/user-id/332696

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors