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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
gjurcin_cch
Frequent Visitor

How to sum a string in matrix as zero value

I have one compex DAX where one division needs to happen and get three different kind of results:

1. if the division is equal to 1 the result needs to be "No data in Lake"

2. if the result have zero denominator then result is "No data in BW"

3. otherwise I want to have regular result

 

Here is the DAX

CALCULATE
(
    IF
    (
        SUMX
        (
            'metadata_data_quality reconcile_status_v1',
            'metadata_data_quality reconcile_status_v1'[kbi_difference]/ABS('metadata_data_quality reconcile_status_v1'[expected_value])
        ) == 1,
        "No data in Lake",
        IF
        (
            ISERROR
            (
                SUMX
                (
                    'metadata_data_quality reconcile_status_v1',
                    'metadata_data_quality reconcile_status_v1'[kbi_difference]/ABS('metadata_data_quality reconcile_status_v1'[expected_value])
                )
            ),
            "No data in BW",
            SUMX
            (
                'metadata_data_quality reconcile_status_v1',
                'metadata_data_quality reconcile_status_v1'[kbi_difference]/ABS('metadata_data_quality reconcile_status_v1'[expected_value])
            )
        )
    ),

    FILTER
    (
        'metadata_data_quality reconcile_status_v1',
        'metadata_data_quality reconcile_status_v1'[process_run_id] == 'metadata_data_quality reconcile_status_v1'[last_process_run_id]
    )
)

 

The formula is working fine but the issue is coming when the matrix is created. Check the image bellow:

 

gjurcin_cch_0-1686416975226.png

 

How can I make subtotal to be zero result if I have more then one values in the columns? Like in the case that I have for "No data in BW". Check the image bellow

 

gjurcin_cch_1-1686417142118.png

 

 

Or even better how can be strings threated as zero value in subtotals and while collapsing the matrix rows?

 

Thank you in advance!

 

 

 

 

1 ACCEPTED SOLUTION

@tamerj1 I have tried with it seems to be very close but now the filter does not take any actions and not working on the context. Can you explain me the meaning of hasonevalue so I can somehow design the dax on my own?

 

SWITCH
(
    TRUE (),
    ISERROR ( ratio ), "No data in BW",
    ratio = 1, "No data in Lake",
    HASONEVALUE ('metadata_data_quality reconcile_status_v1'[fiscper]), ratio,
    "No data in Lake"
)

 

View solution in original post

5 REPLIES 5
tamerj1
Super User
Super User

@gjurcin_cch 

Please try

=
VAR Result =
SUMX (
FILTER (
'metadata_data_quality reconcile_status_v1',
'metadata_data_quality reconcile_status_v1'[process_run_id] = 'metadata_data_quality reconcile_status_v1'[last_process_run_id]
),
'metadata_data_quality reconcile_status_v1'[kbi_difference]
/ ABS ( 'metadata_data_quality reconcile_status_v1'[expected_value] )
)
RETURN
SWITCH (
TRUE (),
ISERROR ( Result ), "No data in BW",
Result = 1, "No data in Lake",
HASONEVALUE ( [YearMonth] ), Result,
"No data in Lake"
)

@tamerj1 I have tried with it seems to be very close but now the filter does not take any actions and not working on the context. Can you explain me the meaning of hasonevalue so I can somehow design the dax on my own?

 

SWITCH
(
    TRUE (),
    ISERROR ( ratio ), "No data in BW",
    ratio = 1, "No data in Lake",
    HASONEVALUE ('metadata_data_quality reconcile_status_v1'[fiscper]), ratio,
    "No data in Lake"
)

 

@gjurcin_cch 

What do you mean by "the filter does not take any actions and not working on the context"?

 

HASONEVALUE checks if the column referred to in its argument has only one value in the current filter context. Basically, for the [fiscper] shall have multiple values in the total column which represents an aggregation of multiple months. Can be also replace with ISINSCOPE that shall act the same in this situation. 

tamerj1
Super User
Super User

Hi @gjurcin_cch 

To be honest, I don't fully understand the requirement. However, I may advise to simplify the measure as follows

=
VAR Result =
SUMX (
FILTER (
'metadata_data_quality reconcile_status_v1',
'metadata_data_quality reconcile_status_v1'[process_run_id] = 'metadata_data_quality reconcile_status_v1'[last_process_run_id]
),
'metadata_data_quality reconcile_status_v1'[kbi_difference]
/ ABS ( 'metadata_data_quality reconcile_status_v1'[expected_value] )
)
RETURN
SWITCH (
TRUE (),
ISERROR ( Result ), "No data in BW",
Result = 1, "No data in Lake",
Result
)

Hi, @tamerj1 thanks for the optimization of the formula it pretty much better than the previous one. But lets get back to the requirement and try to simplify.

 

This is what I have now.

data_lake_object_idexpected_kbi_providerexpected_kbi_namepartition_levelprocess_run_id202100020210202022020Grand Total
cch_bw.mtc.ca_red07_m.v1CA_Q_D_CA_RED07M_Q07ktotalfac0403-RU20230125_003231_4898235_68697  00
   0410-AM20230125_000338_4037250_19423  00
   0415-LV20230125_001908_2470907_24425  00
   0416-EE20230125_001051_6220341_63416No data in LakeNo data in LakeNo data in Lake3
   0417-LT20230125_001812_9030151_77396 No data in LakeNo data in Lake2
   0428-BG20230125_000641_7936029_15792  No data in LakeNo data in Lake
   0430-MK20230125_002029_2134199_19551  00
   0440-RS20230125_002426_3454789_62214  00
   0450-GR20230125_001155_1327277_95418  00
   0470-NG20230125_002126_8875583_13205  00
   0480-GB20230125_001557_2587576_42395  00

 

But I want to have the result below.

 

data_lake_object_idexpected_kbi_providerexpected_kbi_namepartition_levelprocess_run_id202100020210202022020Grand Total
cch_bw.mtc.ca_red07_m.v1CA_Q_D_CA_RED07M_Q07ktotalfac0403-RU20230125_003231_4898235_68697  00
   0410-AM20230125_000338_4037250_19423  00
   0415-LV20230125_001908_2470907_24425  00
   0416-EE20230125_001051_6220341_63416No data in LakeNo data in LakeNo data in Lake0
   0417-LT20230125_001812_9030151_77396 No data in LakeNo data in Lake0
   0428-BG20230125_000641_7936029_15792  No data in LakeNo data in Lake
   0430-MK20230125_002029_2134199_19551  00
   0440-RS20230125_002426_3454789_62214  00
   0450-GR20230125_001155_1327277_95418  00
   0470-NG20230125_002126_8875583_13205  00
   0480-GB20230125_001557_2587576_42395  00

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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