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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
mkinal
Regular Visitor

Assign string value based on multiple criteria

Hi Guys,

 

I have four related tables:

- masterdata_ragwear: stores article information, one side

- article_states: stores one kind of status of articles, one-to-one relation to masterdata_ragwear

- article_filenames: stores sub-items of masterdata_ragwear, many side of the relationship, sub-items are unique

- filetree_ragwear: stores statuses of these sub-itmes, many side of article_filenames, can store multiple values for each status

Annotation 2020-01-27 110833.png

 

I'd like to be able to aggregate statuses of the items of masterdata_ragwear based on multiple criterias coming from the filetree_ragwear and article_states tables and return string values based on the evaluation. This is working until I'm referencing measure values but breaks when I try to assign a custom value to it.

 

Doesn't work if I'm assigning "Not checked in" to the measure:

 

Motive Status = 
VAR selectedAid =
SELECTEDVALUE(masterdata_ragwear[aid])
VAR mStatus =
SWITCH(
    TRUE(),
        ISBLANK([Production Status]),
        "Not checked in",
        
        ISBLANK([Retouch Status]),
        [Production Status],

        [Retouch Status]
)
RETURN
CALCULATE(mStatus, selectedAid=article_filenames[aid])

 

 

Works, because (?) I'm assigning column values:

 

Production Status = 
VAR CheckIns = VALUES(article_states[checked_in])
VAR StatusOut =
    IF(
        NOT ISBLANK(CheckIns),
        VALUES(article_filenames[status])
    )

RETURN
CALCULATE(StatusOut, KEEPFILTERS(CheckIns))

 

 

 

Here's some sample data from each table:

masterdata_ragwear

id, aid, order_number, type. reason. spice_comment, seasonarticle_number, article_name, collection, color_code, color_name, category, physical_sample, recolor_needed, priority, online_shop, gender, ean, quality, clients_comment, comment_logistics, comment_production, comment_art_director, comment_post_production, comment_finance, article_combi, folder, filename, needs_text, deadline, delivery_date, is_fake, fake_ean

428a00000001613500000199normal  SS202011-50005HEAVEN A WHITEX7000WHITEShorts10  Woman4251731826148       2011-50005-7000RAG_2011-50005_7000RAG_2011-50005_70000  0 

 

article_states

id, aid, sent, arrived, checked_in, shoot_bust, shoot_model, shoot_laydown, selected_bust, selected_model, selected_laydown, downloaded, ready_for_texting, boxed, sent_back, last_checked_in

16121a000000016139  Thursday, January 23, 2020       0   
16117a000000016135  Thursday, January 23, 2020       0   
16120a000000016138          0   
16119a000000016137          0   
16118a000000016136          0   

 

article_filesnames

aid, article_motive_id, motive_id, base_name, status

a000000016135203438242RAG_2011-50005_7000_fnew
a000000016135203433247RAG_2011-50005_7000_bnew
a000000016135203434245RAG_2011-50005_7000_dnew
a000000016135203435244RAG_2011-50005_7000_enew
a000000016135203436248RAG_2011-50005_7000_anew
a000000016135203437246RAG_2011-50005_7000_cnew
a000000016135204431487RAG_2011-50005_7000_gnew

 

filetree_ragwear

name, extension, date_modified, date_created, folder_path, base_name, article_name, retouch_status_id

RAG_2011-50005_7000_g.jpg.jpg1/24/2020 7:42:16 PM1/24/2020 7:42:16 PMQ:\Ragwear\02_Model\010-Originals\_sent-to-retouch\20200124_01\RAG_2011-50005_7000\RAG_2011-50005_7000_gRAG_2011-50005_70002
RAG_2011-50005_7000_e.jpg.jpg1/24/2020 7:42:16 PM1/24/2020 7:42:16 PMQ:\Ragwear\02_Model\010-Originals\_sent-to-retouch\20200124_01\RAG_2011-50005_7000\RAG_2011-50005_7000_eRAG_2011-50005_70002
RAG_2011-50005_7000_d.jpg.jpg1/24/2020 7:42:15 PM1/24/2020 7:42:15 PMQ:\Ragwear\02_Model\010-Originals\_sent-to-retouch\20200124_01\RAG_2011-50005_7000\RAG_2011-50005_7000_dRAG_2011-50005_70002
RAG_2011-50005_7000_c.jpg.jpg1/24/2020 7:42:16 PM1/24/2020 7:42:16 PMQ:\Ragwear\02_Model\010-Originals\_sent-to-retouch\20200124_01\RAG_2011-50005_7000\RAG_2011-50005_7000_cRAG_2011-50005_70002
RAG_2011-50005_7000_b.jpg.jpg1/24/2020 7:42:15 PM1/24/2020 7:42:15 PMQ:\Ragwear\02_Model\010-Originals\_sent-to-retouch\20200124_01\RAG_2011-50005_7000\RAG_2011-50005_7000_bRAG_2011-50005_70002
RAG_2011-50005_7000_a.jpg.jpg1/24/2020 7:42:16 PM1/24/2020 7:42:16 PMQ:\Ragwear\02_Model\010-Originals\_sent-to-retouch\20200124_01\RAG_2011-50005_7000\RAG_2011-50005_7000_aRAG_2011-50005_70002

 

Any help would be hugely appreciated!

2 REPLIES 2
amitchandak
Super User
Super User

If the only issue is not checked in is not working. I think because others are numeric

 

Motive Status = 
VAR selectedAid =
SELECTEDVALUE(masterdata_ragwear[aid])
VAR mStatus =
SWITCH(
    TRUE(),
        ISBLANK([Production Status]),
        "Not checked in",
        
        ISBLANK([Retouch Status]),
        [Production Status] & "",

        [Retouch Status] & ""
)
RETURN
CALCULATE(mStatus, selectedAid=article_filenames[aid])

 

but this will make data type as text

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi @amitchandak ,

 

Thanks for the quick reaction! Unfortunetely this isn't solving my problem. All measures should return value type text, so I don't think that's the problem.

 

The problem I have is how to return values (but keep filter context) when the return value is empty. I'd like to list all items from masterdata_ragwear (based on filter context) and display all statuses (including blanks) for them.

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.