Posts

Many-to-many relationship

Image
 How do you handle a 𝗚ð—Ūð—ŧ𝘆-𝘁𝗞-𝗚ð—Ūð—ŧ𝘆 ð—ŋð—ēð—đð—Ū𝘁ð—ķ𝗞ð—ŧ𝘀ð—ĩð—ķð—― in Power BI?" Every analyst knows the answer: "Use a ð—Ŋð—ŋð—ķð—ąð—īð—ē 𝘁ð—Ūð—Ŋð—đð—ē." I gave that answer too. Then I ð—Ŋ𝘂ð—ķð—đ𝘁 it — and ð—ī𝗞𝘁 ð—°ð—žð—šð—―ð—đð—ē𝘁ð—ēð—đ𝘆 𝘄ð—ŋ𝗞ð—ŧð—ī ð—ŧ𝘂𝗚ð—Ŋð—ēð—ŋ𝘀. The bridge table is just the beginning. Here's what's missing 👇 🏗️ 𝗊ð—ĩð—Ū𝘁 ð—Ū ð—Ŋð—ŋð—ķð—ąð—īð—ē 𝘁ð—Ūð—Ŋð—đð—ē ð—Ū𝗰𝘁𝘂ð—Ūð—đð—đ𝘆 ð—ąð—žð—ēs It ð—ģð—ķ𝘅ð—ē𝘀 𝘁ð—ĩð—ē ð—ŋð—ēð—đð—Ū𝘁ð—ķ𝗞ð—ŧ𝘀ð—ĩð—ķð—― 𝘀𝘁ð—ŋ𝘂𝗰𝘁𝘂ð—ŋð—ē, gives Power BI a valid join path. That's it. It does ð—ŧ𝗞𝘁ð—ĩð—ķð—ŧð—ī ð—Ūð—Ŋ𝗞𝘂𝘁 ð—ĩ𝗞𝘄 ð—ģð—ķð—đ𝘁ð—ēð—ŋ𝘀 𝗚𝗞𝘃e during aggregation. ðŸ’Ĩ 𝗧ð—ĩð—ē 𝘀ð—ķð—đð—ēð—ŧ𝘁 ð—―ð—ŋ𝗞ð—Ŋð—đð—ē𝗚 A ð—―ð—đð—Ūð—ķð—ŧ ð—Ķð—Ļ𝗠() measure in a many-to-many setup leads to ð—ąð—žð˜‚ð—Ŋð—đð—ē 𝗰𝗞𝘂ð—ŧ𝘁ð—ķð—ŧð—ī - the same transaction gets counted across overlapping categories.  No errors, no warnings.  Just 𝘄ð—ŋ𝗞ð—ŧð—ī ð—ŧ𝘂𝗚ð—Ŋð—ēð—ŋ𝘀 that look completely fine. ✅ 𝗧ð—ĩð—ē ð—ģ𝘂ð—đð—đ ð—ģð—ķ𝘅 ð—Ķ𝘁ð—ēð—― 𝟭 — 𝗕ð—ŋð—ķð—ąð—īð—ē 𝘁ð—Ūð—Ŋð—đð—ē: resolves model structure. Necessary, but not suf...

Previous week flag

 Is Previous Week = IF(     WEEKNUM('Date'[Date], 2) = WEEKNUM(TODAY(), 2) - 1         && YEAR('Date'[Date]) = YEAR(TODAY()),     1,     0 ) What each part means ðŸ”đ WEEKNUM('Date'[Date], 2) Returns the week number of each date in your Date table 2 → week starts on Monday Week 1 = first week of the year ðŸ”đ WEEKNUM(TODAY(), 2) - 1 Gets current week number Subtracts 1 → gives previous week number 👉 Example: Today → Week 16 Previous week → Week 15 ðŸ”đ YEAR('Date'[Date]) = YEAR(TODAY()) Ensures the date belongs to the current year Prevents mixing weeks from different years ðŸ”đ IF(condition, 1, 0) If both conditions are TRUE → return 1 Else → return 0